Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2011-02-03 14:47:34 -0500
committereutarass2011-02-03 14:47:34 -0500
commit6fb37a78c1c63594a74d7d743838d8d4a81b6912 (patch)
treecfa8869644de2785cc8f65ae767207db9b7ed2cc /main/server.c
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 'main/server.c')
-rw-r--r--main/server.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/main/server.c b/main/server.c
index 91eed512..247d4e5f 100644
--- a/main/server.c
+++ b/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 <main/server.h>
static Protocol * proto;
@@ -33,23 +32,28 @@ static void channel_new_connection(ChannelServer * serv, Channel * c) {
channel_start(c);
}
-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);
-
- if (ps == NULL) {
- fprintf(stderr, "Invalid server URL (-s option value): %s\n", url);
- exit(1);
+ PeerServer * ps = NULL;
+ Trap trap;
+
+ if (!set_trap(&trap)) {
+ bcg = NULL;
+ proto = NULL;
+ if (ps != NULL) peer_server_free(ps);
+ errno = trap.error;
+ return -1;
}
- peer_server_addprop(ps, loc_strdup("ServerManagerID"), loc_strdup(get_service_manager_id(p)));
-
- proto = p;
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("ServerManagerID"), loc_strdup(get_service_manager_id(p)));
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);
+ return 0;
}

Back to the top