]> rtime.felk.cvut.cz Git - frescor/forb.git/blobdiff - src/exec_req.c
Fixed typography.
[frescor/forb.git] / src / exec_req.c
index 22c1eea08301e122ad8c607b72f1ad5cdbd76544..e836dd18b84ccf9b62c87e3d9e2c3ce7eb2c95f2 100644 (file)
 /* however invalidate any other reasons why the executable file might be  */
 /* covered by the GNU Public License.                                    */
 /**************************************************************************/
+/**
+ * @file   exec_req.c
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * @date   Sun Oct 12 16:47:25 2008
+ * 
+ * @brief  Hanlding of requests in executors.
+ * 
+ */
 
 #include "exec_req.h"
 #include "executor.h"
@@ -57,14 +65,14 @@ extern UL_LOG_CUST(ulogd_forb_exec_req);
 
 void forb_exec_req_process(forb_exec_req_t *exec_req)
 {
-       CDR_Codec reply_codec;
+       FORB_CDR_Codec reply_codec;
        struct forb_env env;
        const forb_skel_func *skeletons;
        forb_t *forb = forb_object_to_forb(exec_req->obj);
        CORBA_boolean ret;
        
-       CDR_codec_init_static(&reply_codec);    
-       ret = CDR_buffer_init(&reply_codec, 4096,
+       FORB_CDR_codec_init_static(&reply_codec, exec_req->obj->orb);   
+       ret = FORB_CDR_buffer_init(&reply_codec, 4096,
                              forb_iop_MESSAGE_HEADER_SIZE +
                              forb_iop_REPLY_HEADER_SIZE);
        if (!ret) {
@@ -75,18 +83,29 @@ void forb_exec_req_process(forb_exec_req_t *exec_req)
 
        env.major = FORB_EX_NONE;
 
-       skeletons = exec_req->obj->interface->skeletons;
+       /* Allow the implementation to know about request details
+        * (e.g. source). */
+       exec_req->obj->exec_req = exec_req;
 
        /* Invoke the skeleton */
+       skeletons = exec_req->obj->interface->skeletons;
        skeletons[exec_req->method_index](&exec_req->codec,
                                         &reply_codec,
                                         exec_req->obj,
                                         &env);
-       
-       forb_iop_send_reply(forb, &exec_req->source,
-                           &reply_codec,
-                           exec_req->request_id, &env);
-       forb_free(exec_req);
+
+       // The local invocation case
+       if ((exec_req->request_type = FORB_EXEC_REQ_LOCAL)) {
+               *(exec_req->input_request->cdr_reply) = reply_codec; //FIXME: better without copying?
+               // notify that the reply is ready
+               forb_syncobj_signal(&exec_req->input_request->reply_ready);
+       } else {
+               forb_iop_send_reply(forb, &exec_req->source,
+                               &reply_codec,
+                               exec_req->request_id, &env);            
+       }
+       FORB_CDR_codec_release_buffer(&reply_codec);
+       forb_exec_req_destroy(exec_req);
 }
 
 void forb_exec_req_ins_tail(forb_executor_t *executor,
@@ -101,3 +120,10 @@ void forb_exec_req_ins_tail(forb_executor_t *executor,
        }
        fosa_mutex_unlock(&executor->mutex);
 }
+
+void forb_exec_req_destroy(forb_exec_req_t *exec_req)
+{
+       forb_object_release(exec_req->obj);
+       FORB_CDR_codec_release_buffer(&exec_req->codec);
+       forb_free(exec_req);
+}