+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
+/* */
+/* Universidad de Cantabria, SPAIN */
+/* University of York, UK */
+/* Scuola Superiore Sant'Anna, ITALY */
+/* Kaiserslautern University, GERMANY */
+/* Univ. Politécnica Valencia, SPAIN */
+/* Czech Technical University in Prague, CZECH REPUBLIC */
+/* ENEA SWEDEN */
+/* Thales Communication S.A. FRANCE */
+/* Visual Tools S.A. SPAIN */
+/* Rapita Systems Ltd UK */
+/* Evidence ITALY */
+/* */
+/* See http://www.frescor.org for a link to partners' websites */
+/* */
+/* FRESCOR project (FP6/2005/IST/5-034026) is funded */
+/* in part by the European Union Sixth Framework Programme */
+/* The European Union is not liable of any use that may be */
+/* made of this code. */
+/* */
+/* */
+/* This file is part of FORB (Frescor Object Request Broker) */
+/* */
+/* FORB is free software; you can redistribute it and/or modify it */
+/* under terms of the GNU General Public License as published by the */
+/* Free Software Foundation; either version 2, or (at your option) any */
+/* later version. FORB is distributed in the hope that it will be */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* General Public License for more details. You should have received a */
+/* copy of the GNU General Public License along with FORB; see file */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
+/* Cambridge, MA 02139, USA. */
+/* */
+/* As a special exception, including FORB header files in a file, */
+/* instantiating FORB generics or templates, or linking other files */
+/* with FORB objects to produce an executable application, does not */
+/* by itself cause the resulting executable application to be covered */
+/* by the GNU General Public License. This exception does not */
+/* 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"
#include <stdbool.h>
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) {
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,
}
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);
+}