summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-01-01 16:06:46 +0000
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-01-01 16:06:46 +0000
commitab87627c5c4154a3e30108f7e4dd07f5d95c4390 (patch)
treed6b48456554d83ff384ab95eea98b934d70a0a86 /src/server
parentf4d82deb36b857c6d60d9f31b60d58665a8d6216 (diff)
downloadopenocd_libswd-ab87627c5c4154a3e30108f7e4dd07f5d95c4390.tar.gz
openocd_libswd-ab87627c5c4154a3e30108f7e4dd07f5d95c4390.tar.bz2
openocd_libswd-ab87627c5c4154a3e30108f7e4dd07f5d95c4390.tar.xz
openocd_libswd-ab87627c5c4154a3e30108f7e4dd07f5d95c4390.zip
- add gdb pipe support to native win32 (--pipe option)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1294 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/server')
-rw-r--r--src/server/gdb_server.c2
-rw-r--r--src/server/server.c20
2 files changed, 16 insertions, 6 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 3f9e1e71..eb612c7a 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -126,7 +126,7 @@ int check_pending(connection_t *connection, int timeout_s, int *got_data)
tv.tv_sec = timeout_s;
tv.tv_usec = 0;
- if (select(connection->fd + 1, &read_fds, NULL, NULL, &tv) == 0)
+ if (socket_select(connection->fd + 1, &read_fds, NULL, NULL, &tv) == 0)
{
/* This can typically be because a "monitor" command took too long
* before printing any progress messages
diff --git a/src/server/server.c b/src/server/server.c
index b5b9a205..e97dac9a 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -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)
@@ -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);