switch to jtag_add_callback() - USB performance fix
[openocd.git] / src / server / server.c
index b5b9a205db137564f96583b4160f4b481e2d9ef1..0840c52399c0ef52ccda3c36ea12f3d57c8fb892 100644 (file)
 #include "config.h"
 #endif
 
-#include "replacements.h"
-
 #include "server.h"
-
-#include "log.h"
-#include "telnet_server.h"
 #include "target.h"
 
-#include <command.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
 #include <signal.h>
+
 #ifndef _WIN32
 #include <netinet/tcp.h>
 #endif
 
+
 service_t *services = NULL;
 
 /* shutdown_openocd == 1: exit the main event loop, and quit the debugger */
@@ -58,7 +48,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 +87,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 +212,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 +356,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 +412,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 +494,7 @@ int server_init(void)
        WORD wVersionRequested;
        WSADATA wsaData;
 
-       wVersionRequested = MAKEWORD( 2, 2 );
+       wVersionRequested = MAKEWORD(2, 2);
 
        if (WSAStartup(wVersionRequested, &wsaData) != 0)
        {
@@ -511,7 +502,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);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)