aboutsummaryrefslogtreecommitdiff
path: root/src/transport/wlan
diff options
context:
space:
mode:
authorDavid Brodski <david@brodski.eu>2011-04-12 23:33:44 +0000
committerDavid Brodski <david@brodski.eu>2011-04-12 23:33:44 +0000
commitd47e8be9228c131f93441743c8e90b360d554e9d (patch)
tree9a5d82775a5e7c46ac4ba01784f129a2c8db387c /src/transport/wlan
parentd8cd4422e9d88a0c8180976179662ae2e890db6d (diff)
downloadgnunet-d47e8be9228c131f93441743c8e90b360d554e9d.tar.gz
gnunet-d47e8be9228c131f93441743c8e90b360d554e9d.zip
Big cleanup and heap used for fragments send and with the timeouts
Diffstat (limited to 'src/transport/wlan')
-rw-r--r--src/transport/wlan/loopback_helper.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/transport/wlan/loopback_helper.c b/src/transport/wlan/loopback_helper.c
index ec9096d6f..aa3b6d8af 100644
--- a/src/transport/wlan/loopback_helper.c
+++ b/src/transport/wlan/loopback_helper.c
@@ -27,7 +27,7 @@
27#include "loopback_helper.h" 27#include "loopback_helper.h"
28#include "helper_common.h" 28#include "helper_common.h"
29 29
30extern int first; 30int first;
31 31
32static void 32static void
33sigfunc(int sig) 33sigfunc(int sig)
@@ -114,8 +114,8 @@ testmode(int argc, char *argv[])
114 struct stat st; 114 struct stat st;
115 int erg; 115 int erg;
116 116
117 FILE *fpin; 117 FILE *fpin = NULL;
118 FILE *fpout; 118 FILE *fpout = NULL;
119 119
120 int fdpin; 120 int fdpin;
121 int fdpout; 121 int fdpout;
@@ -165,13 +165,13 @@ testmode(int argc, char *argv[])
165 if (NULL == fpin) 165 if (NULL == fpin)
166 { 166 {
167 fprintf(stderr, "fopen of read FIFO_FILE1\n"); 167 fprintf(stderr, "fopen of read FIFO_FILE1\n");
168 goto end2; 168 goto end;
169 } 169 }
170 fpout = fopen(FIFO_FILE2, "w"); 170 fpout = fopen(FIFO_FILE2, "w");
171 if (NULL == fpout) 171 if (NULL == fpout)
172 { 172 {
173 fprintf(stderr, "fopen of write FIFO_FILE2\n"); 173 fprintf(stderr, "fopen of write FIFO_FILE2\n");
174 goto end1; 174 goto end;
175 } 175 }
176 176
177 } 177 }
@@ -183,34 +183,35 @@ testmode(int argc, char *argv[])
183 if (NULL == fpout) 183 if (NULL == fpout)
184 { 184 {
185 fprintf(stderr, "fopen of write FIFO_FILE1\n"); 185 fprintf(stderr, "fopen of write FIFO_FILE1\n");
186 goto end1; 186 goto end;
187 } 187 }
188 fpin = fopen(FIFO_FILE2, "r"); 188 fpin = fopen(FIFO_FILE2, "r");
189 if (NULL == fpin) 189 if (NULL == fpin)
190 { 190 {
191 fprintf(stderr, "fopen of read FIFO_FILE2\n"); 191 fprintf(stderr, "fopen of read FIFO_FILE2\n");
192 goto end1; 192 goto end;
193 } 193 }
194 194
195
196 } 195 }
197 196
198 fdpin = fileno(fpin); 197 fdpin = fileno(fpin);
198 GNUNET_assert(fpin >= 0);
199
199 if (fdpin >= FD_SETSIZE) 200 if (fdpin >= FD_SETSIZE)
200 { 201 {
201 fprintf(stderr, "File fdpin number too large (%d > %u)\n", fdpin, 202 fprintf(stderr, "File fdpin number too large (%d > %u)\n", fdpin,
202 (unsigned int) FD_SETSIZE); 203 (unsigned int) FD_SETSIZE);
203 close(fdpin); 204 goto end;
204 return -1;
205 } 205 }
206 206
207 fdpout = fileno(fpout); 207 fdpout = fileno(fpout);
208 GNUNET_assert(fdpout >= 0 );
209
208 if (fdpout >= FD_SETSIZE) 210 if (fdpout >= FD_SETSIZE)
209 { 211 {
210 fprintf(stderr, "File fdpout number too large (%d > %u)\n", fdpout, 212 fprintf(stderr, "File fdpout number too large (%d > %u)\n", fdpout,
211 (unsigned int) FD_SETSIZE); 213 (unsigned int) FD_SETSIZE);
212 close(fdpout); 214 goto end;
213 return -1;
214 215
215 } 216 }
216 217
@@ -300,7 +301,7 @@ testmode(int argc, char *argv[])
300 //wait 301 //wait
301 tv.tv_sec = 2; 302 tv.tv_sec = 2;
302 tv.tv_usec = 0; 303 tv.tv_usec = 0;
303 retval = select(0, NULL, NULL, NULL, &tv); 304 select(0, NULL, NULL, NULL, &tv);
304 305
305 while (0 == closeprog) 306 while (0 == closeprog)
306 { 307 {
@@ -346,7 +347,8 @@ testmode(int argc, char *argv[])
346 if (0 > retval) 347 if (0 > retval)
347 { 348 {
348 fprintf(stderr, "select failed: %s\n", strerror(errno)); 349 fprintf(stderr, "select failed: %s\n", strerror(errno));
349 exit(1); 350 closeprog = 1;
351 break;
350 } 352 }
351 353
352 if (FD_ISSET(STDOUT_FILENO, &wfds)) 354 if (FD_ISSET(STDOUT_FILENO, &wfds))
@@ -358,7 +360,7 @@ testmode(int argc, char *argv[])
358 { 360 {
359 closeprog = 1; 361 closeprog = 1;
360 fprintf(stderr, "Write ERROR to STDOUT\n"); 362 fprintf(stderr, "Write ERROR to STDOUT\n");
361 exit(1); 363 break;
362 } 364 }
363 else 365 else
364 { 366 {
@@ -424,7 +426,7 @@ testmode(int argc, char *argv[])
424 { 426 {
425 closeprog = 1; 427 closeprog = 1;
426 fprintf(stderr, "Read ERROR to fdpin: %s\n", strerror(errno)); 428 fprintf(stderr, "Read ERROR to fdpin: %s\n", strerror(errno));
427 closeprog = 1; 429 break;
428 } 430 }
429 else if (0 < readsize) 431 else if (0 < readsize)
430 { 432 {
@@ -445,8 +447,11 @@ testmode(int argc, char *argv[])
445 447
446 GNUNET_SERVER_mst_destroy(stdin_mst); 448 GNUNET_SERVER_mst_destroy(stdin_mst);
447 GNUNET_SERVER_mst_destroy(file_in_mst); 449 GNUNET_SERVER_mst_destroy(file_in_mst);
448 end1: fclose(fpout); 450
449 end2: fclose(fpin); 451 end: if (fpout != NULL)
452 fclose(fpout);
453 if (fpin != NULL)
454 fclose(fpin);
450 455
451 if (1 == first) 456 if (1 == first)
452 { 457 {