Definition in file acceptor.c.
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdlib.h>
#include "acceptor.h"
#include "utils.h"
#include "globals.h"
#include "tcp_accept.h"
#include "config.h"
#include "worker.h"
Go to the source code of this file.
Functions | |
| int | dp_add_pid (pid_t pid) |
| Add a pid to the local process list. | |
| void | dp_del_pid (pid_t pid) |
| Delete a pid from the process list. | |
| void | acceptor_process (dp_config *cfg) |
| Called from diameter_peer_start, after a process was forked for this. | |
| int dp_add_pid | ( | pid_t | pid | ) | [inline] |
Add a pid to the local process list.
| pid | newly forked pid |
Definition at line 95 of file diameter_peer.c.
Referenced by accept_connection(), and diameter_peer_start().
00096 { 00097 pid_list_t *n; 00098 lock_get(pid_list_lock); 00099 n = shm_malloc(sizeof(pid_list_t)); 00100 if (!n){ 00101 LOG_NO_MEM("shm",sizeof(pid_list_t)); 00102 lock_release(pid_list_lock); 00103 return 0; 00104 } 00105 n->pid = pid; 00106 n->next = 0; 00107 n->prev = pid_list->tail; 00108 if (!pid_list->head) pid_list->head = n; 00109 if (pid_list->tail) pid_list->tail->next = n; 00110 pid_list->tail = n; 00111 lock_release(pid_list_lock); 00112 return 1; 00113 }
| void dp_del_pid | ( | pid_t | pid | ) | [inline] |
Delete a pid from the process list.
| pid | - the pid to remove |
Definition at line 132 of file diameter_peer.c.
Referenced by diameter_peer_destroy(), receiver_process(), timer_process(), and worker_process().
00133 { 00134 pid_list_t *i; 00135 lock_get(pid_list_lock); 00136 i = pid_list->head; 00137 if (!i) { 00138 lock_release(pid_list_lock); 00139 return; 00140 } 00141 while(i && i->pid!=pid) i = i->next; 00142 if (i){ 00143 if (i->prev) i->prev->next = i->next; 00144 else pid_list->head = i->next; 00145 if (i->next) i->next->prev = i->prev; 00146 else pid_list->tail = i->prev; 00147 shm_free(i); 00148 } 00149 lock_release(pid_list_lock); 00150 }
| void acceptor_process | ( | dp_config * | cfg | ) |
Called from diameter_peer_start, after a process was forked for this.
| cfg | - the dp_config file, which contains the list of acceptors |
Definition at line 86 of file acceptor.c.
References dp_config::acceptors, dp_config::acceptors_cnt, acceptor_config::bind, create_socket(), listening_socks, LOG_NO_MEM, and acceptor_config::port.
Referenced by diameter_peer_start().
00087 { 00088 int i,k; 00089 unsigned int sock; 00090 00091 LOG(L_INFO,"INFO:Acceptor process starting up...\n"); 00092 listening_socks = pkg_malloc((cfg->acceptors_cnt+1)*sizeof(int)); 00093 if (!listening_socks){ 00094 LOG_NO_MEM("pkg",(cfg->acceptors_cnt+1)*sizeof(int)); 00095 goto done; 00096 } 00097 memset(listening_socks,0,(cfg->acceptors_cnt+1)*sizeof(int)); 00098 k=0; 00099 for(i=0;i<cfg->acceptors_cnt;i++) 00100 if (create_socket(cfg->acceptors[i].port,cfg->acceptors[i].bind,&sock)){ 00101 listening_socks[k++]=sock; 00102 } 00103 00104 00105 LOG(L_INFO,"INFO:... Acceptor opened sockets. Entering accept loop ...\n"); 00106 accept_loop(); 00107 00108 for(i=0;listening_socks[i];i++) 00109 close(listening_socks[i]); 00110 00111 if (listening_socks) pkg_free(listening_socks); 00112 #ifdef CDP_FOR_SER 00113 #else 00114 #ifdef PKG_MALLOC 00115 #ifdef PKG_MALLOC 00116 LOG(memlog, "Acceptor Memory status (pkg):\n"); 00117 //pkg_status(); 00118 #ifdef pkg_sums 00119 pkg_sums(); 00120 #endif 00121 #endif 00122 #endif 00123 dp_del_pid(getpid()); 00124 #endif 00125 done: 00126 LOG(L_INFO,"INFO:... Acceptor process finished\n"); 00127 exit(0); 00128 }
1.5.2