1 /**************************************************************************/
2 /* ---------------------------------------------------------------------- */
3 /* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
5 /* Universidad de Cantabria, SPAIN */
6 /* University of York, UK */
7 /* Scuola Superiore Sant'Anna, ITALY */
8 /* Kaiserslautern University, GERMANY */
9 /* Univ. Politécnica Valencia, SPAIN */
10 /* Czech Technical University in Prague, CZECH REPUBLIC */
12 /* Thales Communication S.A. FRANCE */
13 /* Visual Tools S.A. SPAIN */
14 /* Rapita Systems Ltd UK */
17 /* See http://www.frescor.org for a link to partners' websites */
19 /* FRESCOR project (FP6/2005/IST/5-034026) is funded */
20 /* in part by the European Union Sixth Framework Programme */
21 /* The European Union is not liable of any use that may be */
22 /* made of this code. */
25 /* This file is part of FORB (Frescor Object Request Broker) */
27 /* FORB is free software; you can redistribute it and/or modify it */
28 /* under terms of the GNU General Public License as published by the */
29 /* Free Software Foundation; either version 2, or (at your option) any */
30 /* later version. FORB is distributed in the hope that it will be */
31 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
32 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
33 /* General Public License for more details. You should have received a */
34 /* copy of the GNU General Public License along with FORB; see file */
35 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
36 /* Cambridge, MA 02139, USA. */
38 /* As a special exception, including FORB header files in a file, */
39 /* instantiating FORB generics or templates, or linking other files */
40 /* with FORB objects to produce an executable application, does not */
41 /* by itself cause the resulting executable application to be covered */
42 /* by the GNU General Public License. This exception does not */
43 /* however invalidate any other reasons why the executable file might be */
44 /* covered by the GNU Public License. */
45 /**************************************************************************/
48 * @author Michal Sojka <sojkam1@fel.cvut.cz>
49 * @date Sun Oct 12 16:47:25 2008
51 * @brief Hanlding of requests in executors.
58 #include "forb-internal.h"
64 extern UL_LOG_CUST(ulogd_forb_exec_req);
66 void forb_exec_req_process(forb_exec_req_t *exec_req)
68 FORB_CDR_Codec reply_codec;
70 const forb_skel_func *skeletons;
71 forb_t *forb = forb_object_to_forb(exec_req->obj);
74 FORB_CDR_codec_init_static(&reply_codec, exec_req->obj->orb);
75 ret = FORB_CDR_buffer_init(&reply_codec, 4096,
76 forb_iop_MESSAGE_HEADER_SIZE +
77 forb_iop_REPLY_HEADER_SIZE);
79 /* Without codec, we cannot send any reply so return silently. */
80 ul_logerr("No memory for reply buffer\n");
84 env.major = FORB_EX_NONE;
86 /* Allow the implementation to know about request details
88 exec_req->obj->exec_req = exec_req;
90 /* Invoke the skeleton */
91 skeletons = exec_req->obj->interface->skeletons;
92 skeletons[exec_req->method_index](&exec_req->codec,
97 // The local invocation case
98 if ((exec_req->request_type = FORB_EXEC_REQ_LOCAL)) {
99 forb_request_t *request = exec_req->input_request;
100 forb_executor_t *executor = exec_req->obj->executor;
102 request->cdr_reply = &reply_codec;
103 /* Tell the stub where to signal that reply processing is
105 request->reply_processed = &executor->reply_processed;
106 // notify that the reply is ready
107 forb_syncobj_signal(&request->reply_ready);
108 /* Wait for stub to process the results from the codec's buffer */
109 forb_syncobj_wait(&executor->reply_processed);
111 forb_iop_send_reply(forb, &exec_req->source,
113 exec_req->request_id, &env);
115 FORB_CDR_codec_release_buffer(&reply_codec);
116 forb_exec_req_destroy(exec_req);
119 void forb_exec_req_ins_tail(forb_executor_t *executor,
120 forb_exec_req_t *exec_req)
123 fosa_mutex_lock(&executor->mutex);
124 was_empty = forb_exec_req_nolock_is_empty(executor);
125 forb_exec_req_nolock_ins_tail(executor, exec_req);
127 fosa_cond_signal(&executor->new_request_in_empty_list);
129 fosa_mutex_unlock(&executor->mutex);
132 void forb_exec_req_destroy(forb_exec_req_t *exec_req)
134 forb_object_release(exec_req->obj);
135 FORB_CDR_codec_release_buffer(&exec_req->codec);