X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fserver%2Fserver.c;h=22e01c61eb004df87ff49cf8b122eaf02412fb1a;hb=66add57aa5bae147b7996840a2287f3547b4b8ea;hp=b5b9a205db137564f96583b4160f4b481e2d9ef1;hpb=47d044934727c3d5a57658ddd324b407dd73860a;p=fw%2Fopenocd diff --git a/src/server/server.c b/src/server/server.c index b5b9a205d..22e01c61e 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -58,7 +58,7 @@ int server_use_pipes = 0; int add_connection(service_t *service, command_context_t *cmd_ctx) { - unsigned int address_size; + socklen_t address_size; connection_t *c, **p; int retval; int flag=1; @@ -97,12 +97,11 @@ int add_connection(service_t *service, command_context_t *cmd_ctx) } else if (service->type == CONNECTION_PIPE) { -#ifndef _WIN32 c->fd = service->fd; /* do not check for new connections again on stdin */ service->fd = -1; -#endif + LOG_INFO("accepting '%s' connection from pipe", service->name); if ((retval = service->new_connection(c)) != ERROR_OK) { @@ -223,6 +222,8 @@ int add_service(char *name, enum connection_type type, unsigned short port, int LOG_WARNING("cannot change stdout mode to binary"); if (_setmode(_fileno(stdin), _O_BINARY) < 0) LOG_WARNING("cannot change stdin mode to binary"); + if (_setmode(_fileno(stderr), _O_BINARY) < 0) + LOG_WARNING("cannot change stderr mode to binary"); #else socket_nonblock(c->fd); #endif @@ -365,7 +366,7 @@ int server_loop(command_context_t *command_context) kept_alive(); /* Only while we're sleeping we'll let others run */ - retval = select(fd_max + 1, &read_fds, NULL, NULL, &tv); + retval = socket_select(fd_max + 1, &read_fds, NULL, NULL, &tv); openocd_sleep_postlude(); if (retval == -1) @@ -421,7 +422,7 @@ int server_loop(command_context_t *command_context) if (service->type != CONNECTION_PIPE) { struct sockaddr_in sin; - unsigned int address_size = sizeof(sin); + socklen_t address_size = sizeof(sin); int tmp_fd; tmp_fd = accept(service->fd, (struct sockaddr *)&service->sin, &address_size); close_socket(tmp_fd); @@ -503,7 +504,7 @@ int server_init(void) WORD wVersionRequested; WSADATA wsaData; - wVersionRequested = MAKEWORD( 2, 2 ); + wVersionRequested = MAKEWORD(2, 2); if (WSAStartup(wVersionRequested, &wsaData) != 0) { @@ -511,7 +512,16 @@ int server_init(void) exit(-1); } - SetConsoleCtrlHandler( ControlHandler, TRUE ); + if (server_use_pipes == 0) + { + /* register ctrl-c handler */ + SetConsoleCtrlHandler(ControlHandler, TRUE); + } + else + { + /* we are using pipes so ignore ctrl-c */ + SetConsoleCtrlHandler(NULL, TRUE); + } signal(SIGINT, sig_handler); signal(SIGTERM, sig_handler);