]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
Fixed synchronization for codec buffer.
authorPetr Benes <benesp16@fel.cvut.cz>
Tue, 8 Feb 2011 15:30:23 +0000 (16:30 +0100)
committerPetr Benes <benesp16@fel.cvut.cz>
Tue, 8 Feb 2011 15:30:23 +0000 (16:30 +0100)
src/exec_req.c
src/executor.c
src/executor.h
src/iop.c

index e836dd18b84ccf9b62c87e3d9e2c3ce7eb2c95f2..2f84c103357c72977875b70d93b45208bd6c9a06 100644 (file)
@@ -96,15 +96,23 @@ void forb_exec_req_process(forb_exec_req_t *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?
+               forb_request_t *request = exec_req->input_request;
+               forb_executor_t *executor = exec_req->obj->executor;
+
+               request->cdr_reply = &reply_codec;
+               /* Tell the stub where to signal that reply processing is
+               * finished */
+               request->reply_processed = &executor->reply_processed;          
                // notify that the reply is ready
-               forb_syncobj_signal(&exec_req->input_request->reply_ready);
+               forb_syncobj_signal(&request->reply_ready);
+               /* Wait for stub to process the results from the codec's buffer */              
+               forb_syncobj_wait(&executor->reply_processed);          
        } else {
                forb_iop_send_reply(forb, &exec_req->source,
                                &reply_codec,
                                exec_req->request_id, &env);            
        }
-       FORB_CDR_codec_release_buffer(&reply_codec);
+       FORB_CDR_codec_release_buffer(&reply_codec);                    
        forb_exec_req_destroy(exec_req);
 }
 
index f1a068df6d684e3acd96c79b121d545617d794b8..7e75eb8b33d8a0fe8b76faccfd13109343a106c3 100644 (file)
@@ -86,6 +86,8 @@ int forb_executor_init(forb_executor_t *executor)
        if (ret) return ret;
 
        forb_exec_req_nolock_init_head(executor);
+       
+       forb_syncobj_init(&executor->reply_processed, 0);
        return 0;
 }
 
index 06dddcddcd5bf93bb0f7ae4eb444df41948624a3..f3cad30910da70e071afff5bbab2f09e03020203 100644 (file)
@@ -59,6 +59,8 @@
 #include <fosa.h>
 #include <ul_list.h>
 #include <forb/object_type.h>
+#include <forb/syncobj.h>
+
 
 /**
  * Executor structure.
@@ -74,6 +76,7 @@ typedef struct forb_executor {
        fosa_mutex_t mutex;     /**< Mutex for protecting forb_executor_t::requests. */
        fosa_cond_t new_request_in_empty_list; /**< Signaled when a request was added to the empty list. */
        ul_list_head_t requests; /**< List of pending requests for this executor. */
+       forb_syncobj_t reply_processed;   /**< Synchronization object for signaling the receiver thread to continue processing after the reply is processed by a stub. */       
 } forb_executor_t;
 
 
index f010ac4f3129525bf98f2d044e1ec2ef35ab7179..c7ab0c9eeb6e53dfa3ca469a08400888b42b1551 100644 (file)
--- a/src/iop.c
+++ b/src/iop.c
@@ -759,7 +759,7 @@ forb_request_send(forb_request_t *req, CORBA_Environment *env)
                exec_req->input_request = req;
                exec_req->obj = exec_req->input_request->obj;
                //exec_req->method_index = req.method_index;
-               exec_req->codec = exec_req->input_request->cdr_request; //FIXME: or better without copying?
+               exec_req->codec = exec_req->input_request->cdr_request; 
                exec_req->request_id = exec_req->input_request->request_id;
                forb_exec_req_ins_tail(forb_object_get_executor(exec_req->obj), exec_req);
                return;