diff options
| author | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-07-01 19:35:41 +0000 |
|---|---|---|
| committer | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-07-01 19:35:41 +0000 |
| commit | a5557e562f177e1b2f838fd925026603412f1987 (patch) | |
| tree | 4a3ad1f78f4ca7d8fddcc1d10aa3f08b2229ec7e | |
| parent | efd5d206b65673d751c0aefe540f456fd9d06811 (diff) | |
| download | pica-pica-a5557e562f177e1b2f838fd925026603412f1987.tar.gz pica-pica-a5557e562f177e1b2f838fd925026603412f1987.zip | |
fatal errors
git-svn-id: svn://localhost/project_picapica/trunk@137 fb96df88-216d-11de-830c-f3023f12d8ac
| -rwxr-xr-x | Makefile | 7 | ||||
| -rwxr-xr-x | PICA_node.c | 33 |
2 files changed, 27 insertions, 13 deletions
@@ -1,10 +1,11 @@ -OBJS= PICA_msgproc.o PICA_nodeaddrlist.o PICA_node.o PICA_nodejoinskynet.o PICA_nodeconfig.o iniparser.o dictionary.o +OBJS= PICA_msgproc.o PICA_nodeaddrlist.o PICA_node.o PICA_nodejoinskynet.o PICA_nodeconfig.o iniparser.o dictionary.o PICA_log.o CFLAGS= -pedantic -Wall +LIBS= -lssl -lcrypto -lsqlite3 all: pica-node; pica-node: $(OBJS) - gcc $(OBJS) -l ssl -l crypto -lsqlite3 -o pica-node # добавить CFLAGS и все такое + gcc $(OBJS) $(LIBS) -o pica-node # добавить CFLAGS и все такое PICA_node.o: PICA_node.c PICA_node.h PICA_msgproc.h PICA_nodeaddrlist.h PICA_nodejoinskynet.h PICA_nodeconfig.h gcc $(CFLAGS) -c PICA_node.c @@ -27,5 +28,7 @@ iniparser.o: iniparser/src/iniparser.c dictionary.o: iniparser/src/dictionary.c gcc $(CFLAGS) -c iniparser/src/dictionary.c +PICA_log.o: PICA_log.c PICA_log.h + gcc $(CFLAGS) -c PICA_log.c 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); |
