FACT++  1.0
static int enable_sig ( int  conn_id)
static

Definition at line 355 of file tcpip.c.

References closesock, Curr_N_Conns, DIM_IO_Done, DIM_IO_path, DIM_IO_valid, dim_tcpip_init(), Memory::free(), i, init_done, Memory::malloc(), Net_conns, Threads_on, and Write_buffer_size.

Referenced by tcpip_start_listen(), and tcpip_start_read().

356 {
357  int ret = 1, flags = 1;
358 #ifndef WIN32
359  int pid;
360 #endif
361 
362 #ifdef DEBUG
363  if(!Net_conns[conn_id].channel)
364  {
365  printf("Enabling signals on channel 0\n");
366  fflush(stdout);
367  }
368 #endif
369 
370  if(!init_done)
371  {
372  dim_tcpip_init(0);
373  }
374  if(Threads_on)
375  {
376 #ifdef WIN32
377  DIM_IO_valid = 0;
378 /*
379  ret = connect(DIM_IO_path[0], (struct sockaddr*)&DIM_sockname, sizeof(DIM_sockname));
380 */
382  DIM_IO_path[0] = -1;
383  if( (DIM_IO_path[0] = (int)socket(AF_INET, SOCK_STREAM, 0)) == -1 )
384  {
385  perror("socket");
386  return(1);
387  }
388  ret = ioctl(DIM_IO_path[0], FIONBIO, &flags);
389  if(ret != 0)
390  {
391  perror("ioctlsocket");
392  }
393  DIM_IO_valid = 1;
394 #else
395  if(DIM_IO_path[1] != -1)
396  {
397  if(!DIM_IO_Done)
398  {
399  DIM_IO_Done = 1;
400  write(DIM_IO_path[1], &flags, 4);
401  }
402  }
403 #endif
404  }
405 #ifndef WIN32
406  if(!Threads_on)
407  {
408  pid = getpid();
409 
410 #ifndef __linux__
411  ret = ioctl(Net_conns[conn_id].channel, SIOCSPGRP, &pid );
412 #else
413  ret = fcntl(Net_conns[conn_id].channel,F_SETOWN, pid);
414 #endif
415  if(ret == -1)
416  {
417 #ifdef DEBUG
418  printf("ioctl returned -1\n");
419 #endif
420  return(ret);
421  }
422  }
423  ret = ioctl(Net_conns[conn_id].channel, FIOASYNC, &flags );
424  if(ret == -1)
425  {
426 #ifdef DEBUG
427  printf("ioctl1 returned -1\n");
428 #endif
429  return(ret);
430  }
431 
432  flags = fcntl(Net_conns[conn_id].channel,F_GETFD,0);
433 #ifdef DEBUG
434  if(flags == -1)
435  {
436  printf("error\n");
437  }
438 #endif
439  ret = fcntl(Net_conns[conn_id].channel,F_SETFD, flags | FD_CLOEXEC );
440  if(ret == -1)
441  {
442 #ifdef DEBUG
443  printf("ioctl2 returned -1\n");
444 #endif
445  return(ret);
446  }
447 #endif
448  return(1);
449 }
static int DIM_IO_valid
Definition: tcpip.c:101
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
static int DIM_IO_Done
Definition: tcpip.c:100
static int DIM_IO_path[2]
Definition: tcpip.c:99
int dim_tcpip_init(int thr_flag)
Definition: tcpip.c:235
static int Threads_on
Definition: tcpip.c:90
static int init_done
Definition: tcpip.c:92
#define closesock(s)
Definition: tcpip.c:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function: