server : server.c
+memleak : memleak.c
+
clean :
- @ rm -f server server.o
+ @ rm -f server memleak
+ @ rm -f *.o
CFLAGS = -Wall -D_GNU_SOURCE -g
+LDFLAGS = -g
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <mcheck.h>
+
+int main() {
+
+ for (int i = 0; i < 10; i++) {
+
+ int *leak = (int *) malloc(sizeof(int) * 10);
+ printf("Memory allocated at iteration %d ptr=%p\n",i,leak);
+ (void) sleep(2);
+ }
+
+ return 0;
+}
PROTYP proto; //Connexion protocol type
char *ip; //Binding IP //IPV4 or IPV6
char *port; //Binding Port
+ char *hostname; //binding hostname
time_t lasttry; //successful binding last time
int iteration; //number of soc slot used on the IP
int handle; //connexion handle
register SOCTYP *soc;
soc=(SOCTYP *)socptr;
- soc->port=rou_freestr(soc->port);
+ soc->hostname=rou_freestr(soc->hostname);
soc->ip=rou_freestr(soc->ip);
+ soc->port=rou_freestr(soc->port);
(void) free(soc);
socptr=(SOCPTR *)0;
}
OPEP,strerror(errno));
}
}
- if (contact->carpile!=(char *)0)
- (void) free(contact->carpile);
- if (contact->EOL!=(char *)0)
- (void) free(contact->EOL);
- if (contact->peerip!=(char *)0)
- (void) free(contact->peerip);
- if (contact->locname!=(char *)0)
- (void) free(contact->locname);
+ contact->carpile=rou_freestr(contact->carpile);
+ contact->EOL=rou_freestr(contact->EOL);
+ contact->peerip=rou_freestr(contact->peerip);
+ contact->locname=rou_freestr(contact->locname);
(void) free(contact);
contact=(CONTYP *)0;
}
phase=999; //No End Of Line yet
break;
case 2 : //duplicating carpile
- *lineptr=calloc(tact->carin,sizeof(char));
+ *lineptr=calloc(tact->carin+1,sizeof(char));
*eol='\000';
(void) strcpy(*lineptr,tact->carpile);
(void) strcat(*lineptr,tact->EOL);
char signon[100];
+ (void) prc_settitle("Contact from peer '%s' started at %s",
+ contact->peerip,
+ rou_ascsysstamp(time((time_t *)0)));
(void) snprintf(signon,sizeof(signon),FMT,
SIGNON,contact->locname,
appname,rou_getversion(),
/* */
/********************************************************/
#include <errno.h>
+#include <mcheck.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
TIMESPEC attend;
char *line;
int got;
+ _Bool quit;
- attend.tv_sec=20;
+ attend.tv_sec=60;
attend.tv_nsec=0;
(void) printf("attend %d seconds\n",(int)attend.tv_sec);
got=tcp_getline(contact,&attend,&line);
break; //remote disconnect
}
(void) printf("Read '%d' char =<%s>\n",got,line);
- if (strcasecmp(line,"QUIT"CRLF)==0) {
+ quit=(strcasecmp(line,"QUIT"CRLF)==0);
+ (void) tcp_write(contact,line,strlen(line));
+ (void) free(line);
+ if (quit==true) {
(void) printf("remote quit\n");
break; //remote disconnect
}
- (void) tcp_write(contact,line,strlen(line));
- (void) free(line);
}
break;
case 3 : //connection terminated
//version definition
#define VERSION "0.3"
-#define RELEASE "18"
+#define RELEASE "19"
//Public variables
PUBLIC int debug=0; //debug level