Subversion Repositories HelenOS-historic

Rev

Rev 1709 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1709 Rev 1751
Line 147... Line 147...
147
 
147
 
148
/** Epilogue of ipc_async_send functions */
148
/** Epilogue of ipc_async_send functions */
149
static inline void ipc_finish_async(ipc_callid_t callid, int phoneid,
149
static inline void ipc_finish_async(ipc_callid_t callid, int phoneid,
150
                    async_call_t *call, int can_preempt)
150
                    async_call_t *call, int can_preempt)
151
{
151
{
-
 
152
    if (!call) { /* Nothing to do regardless if failed or not */
-
 
153
        futex_up(&ipc_futex);
-
 
154
        return;
-
 
155
    }
-
 
156
 
152
    if (callid == IPC_CALLRET_FATAL) {
157
    if (callid == IPC_CALLRET_FATAL) {
153
        futex_up(&ipc_futex);
158
        futex_up(&ipc_futex);
154
        /* Call asynchronous handler with error code */
159
        /* Call asynchronous handler with error code */
155
        if (call->callback)
160
        if (call->callback)
156
            call->callback(call->private, ENOENT, NULL);
161
            call->callback(call->private, ENOENT, NULL);
Line 190... Line 195...
190
 */
195
 */
191
void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
196
void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
192
              ipcarg_t arg2, void *private,
197
              ipcarg_t arg2, void *private,
193
              ipc_async_callback_t callback, int can_preempt)
198
              ipc_async_callback_t callback, int can_preempt)
194
{
199
{
195
    async_call_t *call;
200
    async_call_t *call = NULL;
196
    ipc_callid_t callid;
201
    ipc_callid_t callid;
197
 
202
 
-
 
203
    if (callback) {
198
    call = ipc_prepare_async(private, callback);
204
        call = ipc_prepare_async(private, callback);
199
    if (!call)
205
        if (!call)
200
        return;
206
            return;
-
 
207
    }
201
 
208
 
202
    /* We need to make sure that we get callid before
209
    /* We need to make sure that we get callid before
203
     * another thread accesses the queue again */
210
     * another thread accesses the queue again */
204
    futex_down(&ipc_futex);
211
    futex_down(&ipc_futex);
205
    callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2);
212
    callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2);
206
 
213
 
207
    if (callid == IPC_CALLRET_TEMPORARY) {
214
    if (callid == IPC_CALLRET_TEMPORARY) {
-
 
215
        if (!call) {
-
 
216
            call = ipc_prepare_async(private, callback);
-
 
217
            if (!call)
-
 
218
                return;
-
 
219
        }
208
        IPC_SET_METHOD(call->u.msg.data, method);
220
        IPC_SET_METHOD(call->u.msg.data, method);
209
        IPC_SET_ARG1(call->u.msg.data, arg1);
221
        IPC_SET_ARG1(call->u.msg.data, arg1);
210
        IPC_SET_ARG2(call->u.msg.data, arg2);
222
        IPC_SET_ARG2(call->u.msg.data, arg2);
211
    }
223
    }
212
    ipc_finish_async(callid, phoneid, call, can_preempt);
224
    ipc_finish_async(callid, phoneid, call, can_preempt);
Line 340... Line 352...
340
            free(call);
352
            free(call);
341
            return;
353
            return;
342
        }
354
        }
343
    }
355
    }
344
    futex_up(&ipc_futex);
356
    futex_up(&ipc_futex);
345
    printf("Received unidentified answer: %P!!!\n", callid);
357
    /* We may get here after async_msg, which doesn't register any callback */
346
}
358
}
347
 
359
 
348
 
360
 
349
/** One cycle of ipc wait for call call
361
/** One cycle of ipc wait for call call
350
 *
362
 *