Ejemplo n.º 1
0
 int ObTbnetCallback::default_callback(easy_request_t* r)
 {
   int ret = EASY_OK;
   if (NULL == r || NULL == r->ms)
   {
     TBSYS_LOG(WARN, "request is null or r->ms is null");
   }
   else
   {
     easy_session_destroy(r->ms);
   }
   return ret;
 }
Ejemplo n.º 2
0
    int EasyHelper::easy_async_send(easy_io_t *eio,
        const easy_addr_t &addr,
        void *packet,
        void *args,
        easy_io_handler_pt *handler,
        int timeout,
        int retry)
    {
      if (eio == NULL)
      {
        eio = tfs::common::EasyHelper::eio;
      }
      if (handler == NULL)
      {
        handler = tfs::common::EasyHelper::handler;
      }
      if (eio == NULL || handler == NULL || packet == NULL)
      {
        TBSYS_LOG(ERROR, "eio, handler, or packet is null");
        return EASY_ERROR;
      }
      //~ establish one session
      easy_session_t *s = easy_session_create(0);
      if (s == NULL)
      {
        TBSYS_LOG(ERROR, "create easy session failed");
        return EASY_ERROR;
      }
      s->status = EASY_CONNECT_SEND; //~ 5
      s->packet_id = retry;
      s->thread_ptr = handler;
      s->process = (easy_io_process_pt*)handler->process;
      s->cleanup = cleanup_cb;
      easy_session_set_timeout(s, timeout);
      easy_session_set_args(s, args);
      s->r.opacket = packet;

      //~ send
      if (easy_client_dispatch(eio, addr, s) != EASY_OK)
      {
        s->r.opacket = NULL; //! let the caller handle the `packet'
        easy_session_destroy(s);
        return EASY_ERROR;
      }
      return EASY_OK;
    }
Ejemplo n.º 3
0
 void* EasyHelper::easy_sync_send(easy_io_t *eio,
     const easy_addr_t &addr,
     void *packet,
     void *args,
     easy_io_handler_pt *handler,
     int timeout,
     int retry)
 {
   if (eio == NULL)
   {
     eio = tfs::common::EasyHelper::eio;
   }
   if (handler == NULL)
   {
     handler = tfs::common::EasyHelper::handler;
   }
   if (eio == NULL || handler == NULL || packet == NULL)
   {
     TBSYS_LOG(ERROR, "eio, handler, or packet is null");
     return NULL;
   }
   //~ establish one session
   easy_session_t *s = easy_session_create(0);
   if (s == NULL)
   {
     TBSYS_LOG(ERROR, "create easy session failed");
     return NULL;
   }
   s->status = EASY_CONNECT_SEND;
   s->packet_id = retry;
   s->thread_ptr = handler;
   easy_session_set_timeout(s, timeout);
   easy_session_set_args(s, args);
   s->cleanup = cleanup_cb;
   s->r.opacket = packet;
   s->addr = addr;
   //~ send
   void *resp = easy_client_send(eio, addr, s);
   s->r.ipacket = NULL; //~ hand packet to the caller
   easy_session_destroy(s);
   return resp;
 }
Ejemplo n.º 4
0
 int EasyHelper::alive_processor_cb(easy_request_t *r)
 {
   int rc = r->ipacket != NULL ? EASY_OK : EASY_ERROR;
   easy_session_destroy(r->ms);
   return rc;
 }