From: Michal Voců Date: Wed, 20 Jun 2007 09:06:55 +0000 (+0000) Subject: added some error checking X-Git-Tag: gridsite-core_R_1_5_1~3 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=336c383f9543c057d60f5762ea971528ad0e0ecc;p=jra1mw.git added some error checking --- diff --git a/org.glite.lb.logger/src-nt/SocketInput.cpp b/org.glite.lb.logger/src-nt/SocketInput.cpp index f38cabb..14e8df1 100644 --- a/org.glite.lb.logger/src-nt/SocketInput.cpp +++ b/org.glite.lb.logger/src-nt/SocketInput.cpp @@ -6,7 +6,7 @@ #include "ThreadPool.H" #include "SocketInput.H" - +#include "Exception.H" // create unix domain socket for input @@ -21,6 +21,7 @@ SocketInput::SocketInput(const char *path, saddr.sun_family = AF_UNIX; strcpy(saddr.sun_path, path); fd = socket(PF_UNIX, SOCK_STREAM, 0); + if(fd < 0) throw new Exception; if(connect(fd, (struct sockaddr*)&saddr, sizeof(saddr.sun_path)) < 0) { if(errno == ECONNREFUSED) { unlink(saddr.sun_path); @@ -29,8 +30,10 @@ SocketInput::SocketInput(const char *path, // another instance running // throw new Exception } - bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)); - listen(fd, SOCK_QUEUE_MAX); + if(bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) + throw new Exception; + if(listen(fd, SOCK_QUEUE_MAX) < 0) + throw new Exception; ThreadPool::instance()->setWorkAccept(this); }