int main( int argc, char **argv ) { int index = if_nametoindex( "switch0" ); struct ring *ring = create_receiver( index ); if ( debug(argc, argv) ) { exit( 0 ); } receive_loop( ring ); return 0; }
/** * The Receiver Process - calls the receiv_loop and it never returns. * @param p - the peer it is associated with or NULL for the unknown peers receiver * @returns never, when disconnected it will exit */ void receiver_process(peer *p) { LM_INFO("receiver_process(): [%.*s] Receiver process doing init on new process...\n", p?p->fqdn.len:0,p?p->fqdn.s:0); if (p) if (!add_serviced_peer(p)) goto done; LM_INFO("receiver_process(): [%.*s] Receiver process starting up...\n", p?p->fqdn.len:0,p?p->fqdn.s:0); log_serviced_peers(); if (receive_loop(p)<0){ LM_INFO("receiver_process(): [%.*s] receive_loop() return -1 (error)!\n", p?p->fqdn.len:0,p?p->fqdn.s:0); } done: if (!*shutdownx){ LM_INFO("receiver_process(): [%.*s]... Receiver process cleaning-up - should not happen unless shuting down!\n", p?p->fqdn.len:0,p?p->fqdn.s:0); } LM_INFO("receiver_process(): [%.*s]... Receiver process cleaning-up.\n", p?p->fqdn.len:0,p?p->fqdn.s:0); while(serviced_peers){ disconnect_serviced_peer(serviced_peers,0); drop_serviced_peer(serviced_peers,0); } /* remove pid from list of running processes */ dp_del_pid(getpid()); #ifdef CDP_FOR_SER #else #ifdef PKG_MALLOC #ifdef PKG_MALLOC LM_DBG("Receiver[%.*s] Memory status (pkg):\n", p?p->fqdn.len:0,p?p->fqdn.s:0); //pkg_status(); #ifdef pkg_sums pkg_sums(); #endif #endif #endif #endif LM_INFO("receiver_process(): [%.*s]... Receiver process finished.\n", p?p->fqdn.len:0,p?p->fqdn.s:0); exit(0); }
static void receive (krb5_context context, krb5_storage *sp, kadm5_server_context *server_context) { int ret; ret = server_context->db->hdb_open(context, server_context->db, O_RDWR | O_CREAT, 0600); if (ret) krb5_err (context, 1, ret, "db->open"); receive_loop (context, sp, server_context); ret = server_context->db->hdb_close (context, server_context->db); if (ret) krb5_err (context, 1, ret, "db->close"); }
static int overflow_test(void) { int ret = 0; if (opts.dst_addr) { printf("Start testing for fi_send operations: %d\n", (int) max_opts); ret = send_loop(opts.transfer_size); if (ret) printf("ERROR: calling send_master %d\n", ret); } else { printf("Start testing for fi_recv operations: %d\n", (int) max_opts); ret = receive_loop(opts.transfer_size); if (ret) printf("ERROR: calling receive_loop %d\n", ret); } printf("GOOD, Completed Overflow Testing\n"); return 0; }
/** * The Receiver Process - calls the receiv_loop and it never returns. * @param sock - socket to receive data from * @returns never, when disconnected it will exit */ void receiver_process(int sock) { LOG(L_INFO,"INFO:receiver_process(): [%d] Receiver process starting up...\n",sock); receive_loop(sock); LOG(L_INFO,"INFO:receiver_process(): [%d]... Receiver process cleaning-up.\n",sock); close(sock); close(pipe_fd); close(pipe_fd_out); remove(pipe_name.s); if (this_peer){ lock_get(this_peer->lock); this_peer->send_pipe.s=0; this_peer->send_pipe.len=0; lock_release(this_peer->lock); } shm_free(pipe_name.s); //done: /* remove pid from list of running processes */ dp_del_pid(getpid()); #ifdef CDP_FOR_SER drop_my_process(); #else #ifdef PKG_MALLOC #ifdef PKG_MALLOC LOG(memlog, "Receiver[%d] Memory status (pkg):\n",sock); //pkg_status(); #ifdef pkg_sums pkg_sums(); #endif #endif #endif #endif LOG(L_INFO,"INFO:receiver_process(): [%d]... Receiver process finished.\n",sock); exit(0); }
static int receive(krb5_context context, krb5_storage *sp, kadm5_server_context *server_context) { krb5_error_code ret, ret2; ret = server_context->db->hdb_open(context, server_context->db, O_RDWR | O_CREAT, 0600); if (ret) krb5_err(context, IPROPD_RESTART_SLOW, ret, "db->open"); ret2 = receive_loop(context, sp, server_context); if (ret2) krb5_warn(context, ret2, "receive from ipropd-master had errors"); ret = server_context->db->hdb_close(context, server_context->db); if (ret) krb5_err(context, IPROPD_RESTART_SLOW, ret, "db->close"); return ret2; }
void receive_loop(partial_function&& rules) { partial_function tmp(std::move(rules)); receive_loop(tmp); }
void receive_loop(behavior&& rules) { behavior tmp(std::move(rules)); receive_loop(tmp); }