FACT++  1.0
static void recv_rout ( int  conn_id,
DIS_PACKET packet,
int  size,
int  status 
)
static

Definition at line 143 of file dic.c.

References COMMAND, dic_serv::conn_id, Curr_conn_id, Debug_on, Dic_conns, dic_release_service(), Dic_timer_q, dim_panic(), dim_print_date_time(), dll_empty(), dll_get_next(), dna_get_node_task(), Dns_dic_conn_id, do_cmnd_callback(), dtq_clear_entry(), dtq_rem_entry(), execute_service(), id_get_ptr(), locate_command(), MAX_NODE_NAME, MAX_TASK_NAME, move_to_notok_service(), NOT_PENDING, ONCE_ONLY, dic_serv::pending, dic_serv::prev, release_conn(), request_dns_info(), dic_serv::serv_id, dic_serv::serv_name, DIC_CONNECTION::service_head, service_id, DIS_PACKET::service_id, service_tmout(), SRC_DIC, STA_CONN, STA_DATA, STA_DISC, DIC_CONNECTION::task_name, dic_serv::timeout, dic_serv::timer_ent, dic_serv::tmout_done, dic_serv::type, WAITING_CMND_ANSWER, WAITING_DNS_UP, and WAITING_SERVER_UP.

Referenced by dic_find_server_conns(), handle_dns_info(), and open_dns().

144 {
145  register DIC_SERVICE *servp, *auxp;
146  register DIC_CONNECTION *dic_connp;
147  int service_id, once_only, found = 0;
148  char node[MAX_NODE_NAME], task[MAX_TASK_NAME];
149  void move_to_notok_service();
150  void do_cmnd_callback();
151  void dim_panic(char *);
152 
153  dic_connp = &Dic_conns[conn_id] ;
154  switch( status )
155  {
156  case STA_DISC:
157  if(Debug_on)
158  {
159  dna_get_node_task(conn_id, node, task);
161  printf("Conn %d: Server %s on node %s Disconnected\n",
162  conn_id, task, node);
163  fflush(stdout);
164  }
165  if( !(servp = (DIC_SERVICE *) dic_connp->service_head) )
166  {
167  release_conn( conn_id );
168  break;
169  }
170  while( (servp = (DIC_SERVICE *) dll_get_next(
171  (DLL *) dic_connp->service_head,
172  (DLL *) servp)) )
173  {
174 #ifdef DEBUG
175  printf("\t %s was in the service list\n",servp->serv_name);
176  fflush(stdout);
177 #endif
178 /*
179  Will be done later by the DNS answer
180  service_tmout( servp->serv_id );
181 */
182  if(!strcmp(dic_connp->task_name,"DIS_DNS"))
183  {
184  service_tmout( servp->serv_id );
185  }
186  else if(Dns_dic_conn_id <= 0)
187  {
188  service_tmout( servp->serv_id );
189  }
190 /*
191  servp->pending = WAITING_DNS_UP;
192  servp->conn_id = 0;
193 */
194  auxp = servp->prev;
195  move_to_notok_service( servp );
196  servp = auxp;
197  }
198  if( (servp = (DIC_SERVICE *) Cmnd_head) )
199  {
200  while( (servp = (DIC_SERVICE *) dll_get_next(
201  (DLL *) Cmnd_head,
202  (DLL *) servp)) )
203  {
204  if( servp->conn_id == conn_id )
205  {
206 #ifdef DEBUG
207  printf("\t%s was in the Command list\n", servp->serv_name);
208  printf("servp = %x, type = %d, pending = %d\n",servp, servp->type, servp->pending);
209  fflush(stdout);
210 #endif
211  auxp = servp->prev;
212  if( (servp->type == ONCE_ONLY ) &&
213  (servp->pending == WAITING_SERVER_UP))
214  {
215  service_tmout( servp->serv_id );
216  }
217  else if( (servp->type == COMMAND ) &&
218  (servp->pending == WAITING_CMND_ANSWER))
219  {
220  service_tmout( servp->serv_id );
221  }
222  else
223  {
224  servp->pending = WAITING_DNS_UP;
225  dic_release_service( (unsigned)servp->serv_id );
226  }
227  servp = auxp;
228  }
229  }
230  }
231  release_conn( conn_id );
232  request_dns_info(0);
233  break;
234  case STA_DATA:
235  if( !(DIC_SERVICE *) dic_connp->service_head )
236  break;
237  service_id = vtohl(packet->service_id);
238  if((unsigned)service_id & 0x80000000) /* Service removed by server */
239  {
240  service_id &= 0x7fffffff;
241  if( (servp = (DIC_SERVICE *) id_get_ptr(service_id, SRC_DIC)))
242  {
243  if( servp->type != COMMAND )
244  {
245  service_tmout( servp->serv_id );
246 /*
247  servp->pending = WAITING_DNS_UP;
248  servp->conn_id = 0;
249 */
250  move_to_notok_service( servp );
251  }
252  else
253  {
254  service_tmout( servp->serv_id );
255  break;
256  }
257  }
258  else
259  {
260 /*
261  print_packet(packet);
262 */
263  if( (servp = (DIC_SERVICE *) Cmnd_head) )
264  {
265  while( (servp = (DIC_SERVICE *) dll_get_next(
266  (DLL *) Cmnd_head,
267  (DLL *) servp)) )
268  {
269  if( servp->conn_id == conn_id )
270  {
271 #ifdef DEBUG
272  printf("\t%s was in the Command list\n", servp->serv_name);
273  fflush(stdout);
274 #endif
275  auxp = servp->prev;
276  if( (servp->type == ONCE_ONLY ) &&
277  (servp->pending == WAITING_SERVER_UP))
278  {
279  service_tmout( servp->serv_id );
280  }
281  else if( (servp->type == COMMAND ) &&
282  (servp->pending == WAITING_CMND_ANSWER))
283  {
284  service_tmout( servp->serv_id );
285  }
286  else
287  {
288  servp->pending = WAITING_DNS_UP;
289  dic_release_service( (unsigned)servp->serv_id );
290  }
291  servp = auxp;
292  }
293  }
294  }
295  }
296  if( dll_empty((DLL *)dic_connp->service_head) ) {
297  if( (servp = (DIC_SERVICE *) Cmnd_head) ) {
298  while( (servp = (DIC_SERVICE *) dll_get_next(
299  (DLL *) Cmnd_head,
300  (DLL *) servp)) )
301  {
302  if( servp->conn_id == conn_id)
303  found = 1;
304  }
305  }
306  if( !found)
307  {
308  release_conn( conn_id );
309  }
310  }
311  request_dns_info(0);
312  break;
313  }
314  if( (servp = (DIC_SERVICE *) id_get_ptr(service_id, SRC_DIC)))
315  {
316  if(servp->serv_id == service_id)
317  {
318  once_only = 0;
319  if(servp->type == ONCE_ONLY)
320  once_only = 1;
321  else
322  {
323  if( servp->timeout > 0 )
324  {
325  if(servp->timer_ent)
326  dtq_clear_entry( servp->timer_ent );
327  }
328  }
329  Curr_conn_id = conn_id;
330  execute_service(packet, servp, size);
331  Curr_conn_id = 0;
332  if( once_only )
333  {
334  auxp = locate_command(servp->serv_name);
335  if((auxp) && (auxp != servp))
336  {
337  servp->pending = WAITING_DNS_UP;
338  dic_release_service( (unsigned)servp->serv_id );
339  }
340  else
341  {
342  servp->pending = NOT_PENDING;
343  servp->tmout_done = 0;
344  if( servp->timer_ent )
345  {
347  servp->timer_ent = 0;
348  }
349  }
350  }
351  }
352  }
353 /*
354  else
355  {
356  print_packet(packet);
357  if(Error_user_routine)
358  (Error_user_routine)( packet->buffer );
359  }
360 */
361  break;
362  case STA_CONN:
363  if(Debug_on)
364  {
365  dna_get_node_task(conn_id, node, task);
367  printf("Conn %d: Server %s on node %s Connected\n",
368  conn_id, task, node);
369  fflush(stdout);
370  }
371  break;
372  default: dim_panic( "recv_rout(): Bad switch" );
373  }
374 }
#define STA_DATA
Definition: dim.h:198
Definition: dns.c:26
DIM_NOSHARE DIC_CONNECTION * Dic_conns
Definition: conn_handler.c:30
static int Dns_dic_conn_id
Definition: dic.c:46
int tmout_done
Definition: dim.h:477
void move_to_notok_service(DIC_SERVICE *servp)
Definition: dic.c:1655
unsigned service_id
Definition: db_dim_client.c:22
#define STA_DISC
Definition: dim.h:197
#define COMMAND
Definition: dim_common.h:10
char * service_head
Definition: dim.h:424
void * id_get_ptr(int id, SRC_TYPES type)
Definition: conn_handler.c:184
DIC_SERVICE * locate_command(char *serv_name)
Definition: dic.c:1202
void do_cmnd_callback(CMNDCB_ITEM *itemp)
Definition: dic.c:1928
static void release_conn(int conn_id)
Definition: dic.c:2121
static void execute_service(DIS_PACKET *packet, DIC_SERVICE *servp, int size)
Definition: dic.c:376
PENDING_STATES pending
Definition: dim.h:476
int type
Definition: dim.h:465
Definition: dim.h:530
struct dic_serv * prev
Definition: dim.h:459
void dim_panic(char *s)
Definition: utilities.c:198
int dtq_clear_entry(TIMR_ENT *entry)
Definition: dtq.c:490
int dtq_rem_entry(int queue_id, TIMR_ENT *entry)
Definition: dtq.c:503
int conn_id
Definition: dim.h:475
static DIC_SERVICE * Cmnd_head
Definition: dic.c:42
Definition: dim.h:457
#define MAX_TASK_NAME
Definition: dim.h:181
static int Curr_conn_id
Definition: dic.c:54
int service_id
Definition: dim.h:245
int dna_get_node_task(int conn_id, char *node, char *task)
Definition: dna.c:594
int serv_id
Definition: dim.h:461
int dll_empty(DLL *head)
Definition: dll.c:88
static void request_dns_info(int id)
Definition: dic.c:1245
int size
Definition: db_dim_server.c:17
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
#define MAX_NODE_NAME
Definition: dim.h:180
TIMR_ENT * timer_ent
Definition: dim.h:474
char serv_name[MAX_NAME]
Definition: dim.h:460
void service_tmout(int serv_id)
Definition: dic.c:518
void dim_print_date_time()
Definition: utilities.c:134
char task_name[MAX_TASK_NAME]
Definition: dim.h:421
int timeout
Definition: dim.h:466
#define ONCE_ONLY
Definition: dim_common.h:7
void dic_release_service(unsigned service_id)
Definition: dic.c:1025
static int Dic_timer_q
Definition: dic.c:45
#define STA_CONN
Definition: dim.h:199
static int Debug_on
Definition: dic.c:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function: