static int test1() { DCB *dcb; int result; int eno = 0; /* Poll tests */ ss_dfprintf(stderr, "testpoll : Initialise the polling system."); init_test_env(NULL); poll_init(); ss_dfprintf(stderr, "\t..done\nAdd a DCB"); dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER); if(dcb == NULL){ ss_dfprintf(stderr, "\nError on function call: dcb_alloc() returned NULL.\n"); return 1; } dcb->fd = socket(AF_UNIX, SOCK_STREAM, 0); if(dcb->fd < 0){ char errbuf[STRERROR_BUFLEN]; ss_dfprintf(stderr, "\nError on function call: socket() returned %d: %s\n",errno,strerror_r(errno,errbuf,sizeof(errbuf))); return 1; } if((eno = poll_add_dcb(dcb)) != 0){ ss_dfprintf(stderr, "\nError on function call: poll_add_dcb() returned %d.\n",eno); return 1; } if((eno = poll_remove_dcb(dcb)) != 0){ ss_dfprintf(stderr, "\nError on function call: poll_remove_dcb() returned %d.\n",eno); return 1; } if((eno = poll_add_dcb(dcb)) != 0){ ss_dfprintf(stderr, "\nError on function call: poll_add_dcb() returned %d.\n",eno); return 1; } ss_dfprintf(stderr, "\t..done\nStart wait for events."); sleep(10); poll_shutdown(); ss_dfprintf(stderr, "\t..done\nTidy up."); dcb_close(dcb); ss_dfprintf(stderr, "\t..done\n"); return 0; }
/** * Stop a service * * This function stops the listener for the service * * @param service The Service that should be stopped * @return Returns the number of listeners restarted */ int serviceStop(SERVICE *service) { SERV_PROTOCOL *port; int listeners = 0; port = service->ports; while (port) { poll_remove_dcb(port->listener); port->listener->session->state = SESSION_STATE_LISTENER_STOPPED; listeners++; port = port->next; } return listeners; }