summaryrefslogtreecommitdiffstats
path: root/PICA_node.c
diff options
context:
space:
mode:
authorme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2012-07-01 19:35:41 +0000
committerme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2012-07-01 19:35:41 +0000
commita5557e562f177e1b2f838fd925026603412f1987 (patch)
tree4a3ad1f78f4ca7d8fddcc1d10aa3f08b2229ec7e /PICA_node.c
parentefd5d206b65673d751c0aefe540f456fd9d06811 (diff)
downloadpica-pica-a5557e562f177e1b2f838fd925026603412f1987.tar.gz
pica-pica-a5557e562f177e1b2f838fd925026603412f1987.zip
fatal errors
git-svn-id: svn://localhost/project_picapica/trunk@137 fb96df88-216d-11de-830c-f3023f12d8ac
Diffstat (limited to 'PICA_node.c')
-rwxr-xr-xPICA_node.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/PICA_node.c b/PICA_node.c
index 2bcc705..c1f4646 100755
--- a/PICA_node.c
+++ b/PICA_node.c
@@ -16,6 +16,7 @@
#include "PICA_common.h"
#include "PICA_nodejoinskynet.h"
#include "PICA_nodeconfig.h"
+#include "PICA_log.h"
#ifdef NO_RAND_DEV
#include "PICA_rand_seed.h"
@@ -1048,7 +1049,9 @@ WSAStartup(MAKEWORD(2,2),&wsd);
//CONF -AF_INET6 ????
listen_comm_sck=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-//ERR_CHECK
+
+if (listen_comm_sck == -1)
+ PICA_fatal("unable to get socket - %s", strerror(errno));
memset(&sd,0,sizeof(sd));
@@ -1056,9 +1059,15 @@ sd.sin_family=AF_INET;
sd.sin_addr.s_addr=INADDR_ANY;//CONF
sd.sin_port = (nodecfg.listen_port ? htons(atoi(nodecfg.listen_port)) : htons(PICA_COMM_PORT));//CONF
-bind(listen_comm_sck,(struct sockaddr*)&sd,sizeof(sd));
-listen(listen_comm_sck,20);
-//ERR_CHECK
+ret = bind(listen_comm_sck,(struct sockaddr*)&sd,sizeof(sd));
+
+if (ret == -1)
+ PICA_fatal("unable to bind socket - %s", strerror(errno));
+
+
+ret = listen(listen_comm_sck,20);
+if (ret == -1)
+ PICA_fatal("unable to listen socket - %s", strerror(errno));
{
int ret_comm;
@@ -1072,22 +1081,24 @@ ret_comm=ioctl(listen_comm_sck,FIONBIO,(int*)&arg);
// ret_data=ioctl(listen_data_sck,FIONBIO,(int*)&arg);
// ret_data=ioctl(listen_node_sck,FIONBIO,(int*)&arg);
#endif
-printf("ioctl ret_comm=%i\n",ret_comm);//debug
+if (ret_comm == -1)
+ PICA_fatal("unable to set non-blocking mode on socket - %s", strerror(errno));
}
-#ifdef NO_RAND_DEV
-PICA_rand_seed();
-#endif
+//#ifdef NO_RAND_DEV
+//PICA_rand_seed();
+//#endif
-ctx=SSL_CTX_new(TLSv1_method());
+ctx = SSL_CTX_new(TLSv1_method());
if (!ctx)
-;//ERR_CHECK
+ PICA_fatal("unable to create SSL_CTX object");
ret = SSL_CTX_load_verify_locations(ctx, nodecfg.CA_cert_file, 0);
-;//ERR_CHECK
+if (!ret)
+ PICA_fatal("call to SSL_CTX_load_verify_locations failed(). Check if %s exists and is accesible", nodecfg.CA_cert_file);
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL);