FACT++  1.0
void dis_send_service ( unsigned  service_id,
int *  buffer,
int  size 
)

Definition at line 2053 of file dis.c.

References DIS_PACKET::buffer, req_ent::conn_id, DIM_ERROR, dim_print_date_time(), DIMSVCINVAL, DIS_HEADER, dll_get_next(), dna_write_nowait(), error_handler(), Memory::free(), id_get_ptr(), Memory::malloc(), Net_conns, release_conn(), serv::request_head, req_ent::service_id, DIS_PACKET::service_id, size, DIS_PACKET::size, sprintf(), SRC_DIS, and str.

Referenced by dis_hash_print().

2054 {
2055  register REQUEST *reqp, *prevp;
2056  register SERVICE *servp;
2057  static DIS_PACKET *dis_packet;
2058  static int packet_size = 0;
2059  int conn_id;
2060  char str[128];
2061 
2062  DISABLE_AST
2063  if( !service_id ) {
2064  sprintf(str,"Send Service - Invalid service id");
2065  error_handler(0, DIM_ERROR, DIMSVCINVAL, str, -1);
2066  ENABLE_AST
2067  return;
2068  }
2069  servp = (SERVICE *)id_get_ptr(service_id, SRC_DIS);
2070  if(!servp)
2071  {
2072  ENABLE_AST
2073  return;
2074  }
2075  if(!packet_size)
2076  {
2077  dis_packet = (DIS_PACKET *)malloc((size_t)(DIS_HEADER+size));
2078  packet_size = DIS_HEADER + size;
2079  }
2080  else
2081  {
2082  if( DIS_HEADER+size > packet_size )
2083  {
2084  free(dis_packet);
2085  dis_packet = (DIS_PACKET *)malloc((size_t)(DIS_HEADER+size));
2086  packet_size = DIS_HEADER+size;
2087  }
2088  }
2089  prevp = servp->request_head;
2090  while( (reqp = (REQUEST *) dll_get_next((DLL *)servp->request_head,
2091  (DLL *) prevp)) )
2092  {
2093  dis_packet->service_id = htovl(reqp->service_id);
2094  memcpy(dis_packet->buffer, buffer, (size_t)size);
2095  dis_packet->size = htovl(DIS_HEADER + size);
2096 
2097  conn_id = reqp->conn_id;
2098  if( !dna_write_nowait(conn_id, dis_packet, size + DIS_HEADER) )
2099  {
2101  printf(" Server Sending Service: Couldn't write to Conn %3d : Client %s@%s\n",conn_id,
2102  Net_conns[conn_id].task, Net_conns[conn_id].node);
2103  fflush(stdout);
2104  release_conn(conn_id, 1, 0);
2105  }
2106  else
2107  prevp = reqp;
2108  }
2109  ENABLE_AST
2110 }
Definition: dns.c:26
static void error_handler(int conn_id, int severity, int errcode, char *reason, int exit)
Definition: dis.c:3199
unsigned service_id
Definition: db_dim_client.c:22
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
char str[80]
Definition: test_client.c:7
void * id_get_ptr(int id, SRC_TYPES type)
Definition: conn_handler.c:184
int service_id
Definition: dis.c:56
void * malloc()
Definition: EventBuilder.cc:99
static int release_conn(int conn_id, int print_flg, int dns_flag)
Definition: dis.c:2684
Definition: dim.h:530
Definition: dis.c:69
REQUEST * request_head
Definition: dis.c:86
int size
Definition: dim.h:244
int service_id
Definition: dim.h:245
#define DIMSVCINVAL
Definition: dim_common.h:290
int dna_write_nowait(int conn_id, void *buffer, int size)
Definition: dna.c:412
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
int size
Definition: db_dim_server.c:17
int buffer[1]
Definition: dim.h:246
void free(void *mem)
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
void dim_print_date_time()
Definition: utilities.c:134
#define DIS_HEADER
Definition: dim.h:249
int conn_id
Definition: dis.c:55
Definition: dis.c:52
sprintf(name1,"NewService%d", i)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: