bugfix
Hezekiah <[email protected]>
| Newsgroups | gmane.comp.security.invisiblenet.iip.devel |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Oops. The patch I posted previously looks like my mail client wraped some of the code on to the next line. (Can you say syntax error?) :) I've attached a normal version to this message as a text file. Sincerely, Hezekiah -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9pH/1eHiZTMH32ioRAss6AJ91Enb0gaXDPStLMlbD7SYUlR6nLACeKOeN ueOCGgzKOgyuKH+hFEtdI9g= =2rAD -----END PGP SIGNATURE-----
patch1.txt
(text/plain, 4.6 KB)
Index: iip/iip.c
===================================================================
RCS file: /cvsroot/invisibleip/iip/src/iip/iip.c,v
retrieving revision 1.28
diff -u -3 -p -r1.28 iip.c
--- iip/iip.c 9 Oct 2002 01:44:42 -0000 1.28
+++ iip/iip.c 9 Oct 2002 19:09:12 -0000
@@ -292,9 +292,7 @@ int init() {
#endif
// enter the main loop
- coreMainLoop();
-
- return 0;
+ return !coreMainLoop() ? 0 : 30; //todo: what exit code should this be?
}
Index: msgcore/core.c
===================================================================
RCS file: /cvsroot/invisibleip/iip/src/msgcore/core.c,v
retrieving revision 1.9
diff -u -3 -p -r1.9 core.c
--- msgcore/core.c 9 Oct 2002 01:44:26 -0000 1.9
+++ msgcore/core.c 9 Oct 2002 19:09:17 -0000
@@ -216,23 +216,25 @@ void coreProcessMessageQueue(void) {
}
}
-void coreStart(void) {
+int coreStart(void) {
// NodeRef *nr = noderefMake();
sockservInit(coreAddInSock);
coreInit();
- sockservStartListen();
+ // abort if we couldn't start up the socket(s)
+ if(sockservStartListen()) {return -1;}
// noderefInit(nr, "0.0.0.0", "plain", localPort);
// sockservListen(nr);
// noderefFree(nr);
+ return 0; // success
}
-void coreMainLoop(void) {
+int coreMainLoop(void) {
//int i = 0;
- coreStart();
+ if(coreStart()) {return -1;}
while(1) {
#ifdef _WINDOZE_
if(dowindows()) {
@@ -241,6 +243,8 @@ void coreMainLoop(void) {
#endif
coreMainPoll(0);
}
+
+ return 0; // success
}
void coreMainPoll(int shortdelay) {
Index: msgcore/core.h
===================================================================
RCS file: /cvsroot/invisibleip/iip/src/msgcore/core.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 core.h
--- msgcore/core.h 9 Oct 2002 01:44:26 -0000 1.3
+++ msgcore/core.h 9 Oct 2002 19:09:17 -0000
@@ -11,12 +11,12 @@ void coreInit(void);
void coreAddInSock(SockHandle *sh, int *result);
PipeFace *coreMakeConnection(int retries);
void coreSwapPipeFace(PipeFace *oldpf, PipeFace *newpf);
-void coreMainLoop(void);
+int coreMainLoop(void);
void coreMainPoll(int shortdelay);
void coreProcessMessageQueue(void);
void coreProcessPipeFace(void);
-void coreStart(void);
+int coreStart(void);
#endif //CORE_CORE_H
Index: net/sockserv.c
===================================================================
RCS file: /cvsroot/invisibleip/iip/src/net/sockserv.c,v
retrieving revision 1.5
diff -u -3 -p -r1.5 sockserv.c
--- net/sockserv.c 9 Oct 2002 01:46:12 -0000 1.5
+++ net/sockserv.c 9 Oct 2002 19:09:23 -0000
@@ -285,11 +285,11 @@ SockHandle *sockservListen(NodeRef *nr)
return sh;
}
-void sockservStartListen(void) {
+int sockservStartListen(void) {
int i;
//sockservInit();
if(SocksListening == NULL) {
- return;
+ return 1;
}
//close any open listening sockets
for(i = 0; i < SocksListening->size; i++) {
@@ -312,7 +312,26 @@ void sockservStartListen(void) {
")",
ptrToString(&LNRA->data[i]),
NULL));
- sockservListen(&LNRA->data[i]);
+ if(!sockservListen(&LNRA->data[i])) { // if the listen failed
+ //close any open listening sockets
+ for(i = 0; i < SocksListening->size; i++) {
+ if(SocksListening->data[i] != NULL) {
+ LOGDEBUG(stringJoinMany(
+ "sockservStartListen:Close:(",
+ intToString(i),
+ ")",
+ ptrToString(SocksListening->data[i]),
+ NULL));
+
+ sockClose(SocksListening->data[i]);
+ sockFree(SocksListening->data[i]);
+ SocksListening->data[i] = NULL;
+ }
+ }
+
+ return -1; // can't bind the socket; bail out
+ }
}
+ return 0; // success
}
Index: net/sockserv.h
===================================================================
RCS file: /cvsroot/invisibleip/iip/src/net/sockserv.h,v
retrieving revision 1.2
diff -u -3 -p -r1.2 sockserv.h
--- net/sockserv.h 9 Oct 2002 01:46:12 -0000 1.2
+++ net/sockserv.h 9 Oct 2002 19:09:25 -0000
@@ -28,7 +28,7 @@ void sockservProcess(int shortdelay);
SockHandle *sockservConnect(void);
SockHandle *sockservListen(NodeRef *nr);
-void sockservStartListen(void);
+int sockservStartListen(void);
//internal functions