Skip to main content
summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authoreutarass2011-02-03 14:47:34 -0500
committereutarass2011-02-03 14:47:34 -0500
commit6fb37a78c1c63594a74d7d743838d8d4a81b6912 (patch)
treecfa8869644de2785cc8f65ae767207db9b7ed2cc /server
parent69b248a3dc164e354969a98ddc637c1ee3d6cd47 (diff)
downloadorg.eclipse.tcf.agent-6fb37a78c1c63594a74d7d743838d8d4a81b6912.tar.gz
org.eclipse.tcf.agent-6fb37a78c1c63594a74d7d743838d8d4a81b6912.tar.xz
org.eclipse.tcf.agent-6fb37a78c1c63594a74d7d743838d8d4a81b6912.zip
TCF Agent: fixed: ini_server() function should return an error code instead of calling exit(1) on error
Diffstat (limited to 'server')
-rw-r--r--server/main/server.c34
-rw-r--r--server/server.vcproj4
2 files changed, 24 insertions, 14 deletions
diff --git a/server/main/server.c b/server/main/server.c
index ad375103..b4635ef4 100644
--- a/server/main/server.c
+++ b/server/main/server.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -18,9 +18,8 @@
#include <config.h>
-#include <stdio.h>
-#include <framework/errors.h>
#include <framework/myalloc.h>
+#include <framework/exceptions.h>
#include <framework/proxy.h>
#include <services/linenumbers.h>
#include <services/symbols.h>
@@ -69,23 +68,30 @@ static void channel_redirection_listener(Channel * host, Channel * target) {
}
}
-void ini_server(const char * url, Protocol * p, TCFBroadcastGroup * b) {
+int ini_server(const char * url, Protocol * p, TCFBroadcastGroup * b) {
ChannelServer * serv = NULL;
- PeerServer * ps = channel_peer_from_url(url);
+ PeerServer * ps = NULL;
+ Trap trap;
- if (ps == NULL) {
- fprintf(stderr, "Invalid server URL (-s option value): %s\n", url);
- exit(1);
+ if (!set_trap(&trap)) {
+ bcg = NULL;
+ proto = NULL;
+ if (ps != NULL) peer_server_free(ps);
+ errno = trap.error;
+ return -1;
}
+
+ bcg = b;
+ proto = p;
+ ps = channel_peer_from_url(url);
+ if (ps == NULL) str_exception(ERR_OTHER, "Invalid server URL");
peer_server_addprop(ps, loc_strdup("Name"), loc_strdup("TCF Proxy"));
peer_server_addprop(ps, loc_strdup("Proxy"), loc_strdup(""));
- proto = p;
- bcg = b;
serv = channel_server(ps);
- if (serv == NULL) {
- fprintf(stderr, "Cannot create TCF server: %s\n", errno_to_str(errno));
- exit(1);
- }
+ if (serv == NULL) exception(errno);
serv->new_conn = channel_new_connection;
+
+ clear_trap(&trap);
add_channel_redirection_listener(channel_redirection_listener);
+ return 0;
}
diff --git a/server/server.vcproj b/server/server.vcproj
index 04943e17..0b66ac5b 100644
--- a/server/server.vcproj
+++ b/server/server.vcproj
@@ -323,6 +323,10 @@
>
</File>
<File
+ RelativePath="..\agent\main\server.h"
+ >
+ </File>
+ <File
RelativePath="..\agent\main\services.c"
>
</File>

Back to the top