本文整理汇总了C++中shutdown_server函数的典型用法代码示例。如果您正苦于以下问题:C++ shutdown_server函数的具体用法?C++ shutdown_server怎么用?C++ shutdown_server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shutdown_server函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: end_test
static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
grpc_completion_queue_shutdown(f->cq);
drain_cq(f->cq);
grpc_completion_queue_destroy(f->cq);
}
示例2: end_test
static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
grpc_completion_queue_shutdown(f->cq);
drain_cq(f->cq);
grpc_completion_queue_destroy(f->cq);
/* Note: shutdown_cq is not used in this test */
grpc_completion_queue_destroy(f->shutdown_cq);
}
示例3: console_shutdown
static void console_shutdown(connection_type* ct, char *when)
{
int min = 0;
//if (!my_stricmp(when, "NOW")) min = 0;
//else if (IS_VALID_NUMBER(when)) min = when
/* Now */
if (min == 0)
{
/* Tell */
cq_printf(&ct->wbuf, "%T", "Server shutdown\n");
/* Shutdown */
shutdown_server();
}
else
/* Delayed */
{
/* Set timer (in seconds) */
shutdown_timer= min * 60;
}
}
示例4: main
int main(int argc, char** argv) {
int port = atoi(argv[1]);
Server* server = create_server(port);
listen_port(server);
Connection* con = accept_connection(server);
char client_addr[50];
get_connection_address(con, client_addr);
printf("CLIENT %s CONNECTED\n", client_addr);
receive_greet(con);
send_greet_ack(con);
//Receive folder anem
char buffer[MAX_MSG];
receive_msg(con, buffer);
send_ack(con);
char filename[100];
strcpy(filename, client_addr);
strcat(filename, buffer);
int i;
for(i = 0; filename[i] != '\0'; i++){
filename[i] = filename[i] == '/'? '.': filename[i];
}
char* filebuffer = calloc(sizeof(char), MAX_MSG);
int filebuffer_size = MAX_MSG;
filebuffer[0] = '\0';
int usedbuffer = 0;
//receive filenames
while(receive_msg(con, buffer)){
usedbuffer += strlen(buffer)+1;
if(usedbuffer > filebuffer_size){
filebuffer_size *= 2;
filebuffer = (char*) realloc(filebuffer, sizeof(char)*filebuffer_size*2);
}
printf("%s\n", buffer);
sprintf(filebuffer, "%s%s\n", filebuffer, buffer);
send_ack(con);
}
shutdown_server(server);
close_connection(con);
FILE* f = fopen(filename, "w");
fprintf(f, "%s", filebuffer);
fclose(f);
free(filebuffer);
return 0;
}
示例5: main
/**
* Point d'entrée du programme.
*/
int main(int argc, char *argv[])
{
parse_command_line(argc, argv);
/* On crée un socket pour se connecter sur un serveur */
if ((server_socket = socket(PF_INET, SOCK_STREAM, 0)) == -1)
{
perror("socket");
return EXIT_FAILURE;
}
/* Initialisation du bind */
memset(&server_address, 0, sizeof server_address);
server_address.sin_family = AF_INET;
server_address.sin_addr.s_addr = htonl(INADDR_ANY);
server_address.sin_port = htons(port);
/* Ze bind */
if (bind(server_socket, (struct sockaddr *) &server_address, sizeof(server_address)) == -1)
{
perror("bind");
if (close(server_socket) == -1)
perror("Impossible de fermer le socket serveur");
return EXIT_FAILURE;
}
/* On le définit comme écouteur */
if (listen(server_socket, MAX_CLIENT) == -1)
{
perror("Impossible de mettre le socket serveur en écoute");
if (close(server_socket) == -1)
perror("Impossible de fermer le socket serveur");
return EXIT_FAILURE;
}
verbose("Démarrage du démon sur le port %d ...\n", port);
/* Pour quitter le serveur proprement */
signal(SIGINT, trap_ctrlc);
for (;;) {
/* Variable concrète car il faut pouvoir en avoir l'adresse pour accept() */
socklen_t client_address_size = sizeof client_address;
/* On attend une connection */
if ((client_socket = accept(server_socket, (struct sockaddr *) &client_address, &client_address_size)) == -1)
{
perror("accept");
if (close(server_socket) == -1)
perror("Impossible de fermer le socket serveur");
return EXIT_FAILURE;
}
/* On traite ce client */
process_client();
}
shutdown_server(); /* N'arrivera jamais */
return EXIT_FAILURE;
}
示例6: trap_ctrlc
/**
* Fonction de callback appelée lors d'un ctrl+c.
*/
static void trap_ctrlc(int sig)
{
sig = sig; /* Evite un warning */
shutdown_server();
}
示例7: exec_shutdown_maxscale
/**
* MaxScale shutdown
* @param dcb Client DCB
* @param tree Parse tree
*/
void exec_shutdown_maxscale(DCB *dcb, MAXINFO_TREE *tree)
{
shutdown_server();
maxinfo_send_ok(dcb);
}
示例8: main
//.........这里部分代码省略.........
/* initialize webserver */
if (!init_server(crtpath, qpath, rqpath, lsthost, lstport)) {
flog(LOG_ERR, "failed to initialize webserver");
return EXIT_FAILURE;
}
/* try to reregister watches as long as no signal caught */
for (lastclock = getmontime(), retryid = 0; !stop_requested(); ) {
/* support empty CABLE_NOLOOP when testing, to act as pure server */
#ifdef TESTING
if (getenv("CABLE_NOLOOP")) {
sleepsec(RETRY_TMOUT);
continue;
}
#endif
wait_reg_watches(qpath, rqpath);
/* read events as long as no signal caught and no unmount / move_self / etc. events read */
for (rereg = evqok = 0; !stop_requested() && !rereg; ) {
/* wait for an event, or timeout (later blocking read() results in error) */
retrytmout = RETRY_TMOUT + RETRY_TMOUT * (rand_shift() / 2);
if (wait_read(inotfd, retrytmout - (getmontime() - lastclock))) {
/* read events (non-blocking), taking care to handle interrupts due to signals */
if ((sz = read(inotfd, buf, sizeof(buf))) == -1 && errno != EINTR) {
/* happens buffer is too small (e.g., NTFS + 255 unicode chars) */
warning("error while reading from inotify queue");
rereg = 1;
}
/* process all events in buffer, sz = -1 and 0 are automatically ignored */
for (offset = 0; offset < sz && !stop_requested() && !rereg; evqok = 1) {
/* get handler to next event in read buffer, and update offset */
iev = (struct inotify_event*) (buf + offset);
offset += sizeof(struct inotify_event) + iev->len;
/*
IN_IGNORED is triggered by watched directory removal / fs unmount
IN_MOVE_SELF is only triggered by move of actual watched directory
(i.e., not its parent)
*/
if ((iev->mask & (IN_IGNORED | IN_UNMOUNT | IN_Q_OVERFLOW | IN_MOVE_SELF)))
rereg = 1;
/* ignore non-subdirectory events, and events with incorrect name */
else if (iev->len > 0 && (iev->mask & IN_ISDIR) && is_msgdir(iev->name)) {
assert(iev->wd == inotqwd || iev->wd == inotrqwd);
if (iev->wd == inotqwd || iev->wd == inotrqwd) {
/* stop can be indicated here (while waiting for less processes) */
const char *qtype = (iev->wd == inotqwd) ? QUEUE_NAME : RQUEUE_NAME;
run_loop(qtype, iev->name, looppath);
}
else
flog(LOG_WARNING, "unknown watch descriptor");
}
}
}
/*
if sufficient time passed since last retries, retry again
*/
if (!stop_requested() && getmontime() - lastclock >= retrytmout) {
/* alternate between queue dirs to prevent lock starvation on self-send */
if ((retryid ^= 1))
retry_dir(QUEUE_NAME, qpath, looppath);
else
retry_dir(RQUEUE_NAME, rqpath, looppath);
lastclock = getmontime();
/* inotify is apparently unreliable on fuse, so reregister when no events */
if (!evqok)
rereg = 1;
evqok = 0;
}
}
}
unreg_watches();
if (!shutdown_server())
flog(LOG_WARNING, "failed to shutdown webserver");
dealloc_env(lstport);
dealloc_env(lsthost);
dealloc_env(looppath);
dealloc_env(rqpath);
dealloc_env(qpath);
dealloc_env(crtpath);
flog(LOG_INFO, "exiting");
closelog();
return EXIT_SUCCESS;
}
示例9: iuctl_server_shutdown
void iuctl_server_shutdown() {
destroy_iuctl();
shutdown_server();
exit(0);
}