Revision 4f1a41e6

View differences:

transmissionHandler.c
424 424
	    // otherwise just write the connection cb and the arg pointer
425 425
	    // into the connection struct
426 426
	    else {
427

  
428
		connectbuf[i]->connection_cb_2 = connection_cb;
429
		connectbuf[i]->arg_2 = arg;
430

  
427
			receive_connection_cb_list *temp;
428
			temp = malloc(sizeof(receive_connection_cb_list));
429
			temp->next = connectbuf[i]->connection_last;
430
			temp->connection_cb = connection_cb;
431
			temp->arg = arg;
432
			connectbuf[i]->connection_last = temp;
431 433
	    }
432 434

  
433 435
	} else {
......
463 465
		    connectbuf[i]->timeout_value.tv_sec = 15;
464 466
		    connectbuf[i]->timeout_value.tv_usec = 0;
465 467
		    connectbuf[i]->connectionID = i;
466
		    connectbuf[i]->connection_cb_1 = connection_cb;
467
		    connectbuf[i]->arg_1 = arg;
468 468
		    *connectionID = i;
469 469
		    setEntry = true;
470

  
471
			 connectbuf[i]->connection_head = connectbuf[i]->connection_last = malloc(sizeof(receive_connection_cb_list));
472
			 connectbuf[i]->connection_last->next = NULL;
473
			 connectbuf[i]->connection_last->connection_cb = connection_cb;
474
			 connectbuf[i]->connection_last->arg = arg;
475

  
470 476
		    break;
471 477
		}
472 478

  
......
1312 1318
		if (connectbuf[i] == NULL) {
1313 1319

  
1314 1320
		    connectbuf[i] = (connect_data *) malloc(sizeof(connect_data));
1321
			 connectbuf[i]->connection_head = connectbuf[i]->connection_last = NULL;
1315 1322
		    connectbuf[i]->starttime = time(NULL);
1316 1323
		    connectbuf[i]->external_socketID = external_socketID;
1317 1324
		    connectbuf[i]->pmtusize = pmtusize;
......
1383 1390
	    if (receive_Connection_cb != NULL)
1384 1391
		(receive_Connection_cb) (internal_connectionID, NULL);
1385 1392

  
1386
	    if (connectbuf[internal_connectionID]->connection_cb_1 != NULL) {
1387 1393

  
1388
		(connectbuf[internal_connectionID]->
1389
		 connection_cb_1) (internal_connectionID,
1390
				   connectbuf[internal_connectionID]->
1391
				   arg_1);
1394
		 while(connectbuf[internal_connectionID]->connection_head != NULL) {
1395
			receive_connection_cb_list *temp;
1396
			temp = connectbuf[internal_connectionID]->connection_head;
1397
			(temp->connection_cb) (internal_connectionID, temp->arg);
1398
			connectbuf[internal_connectionID]->connection_head = temp->next;
1399
			free(temp);
1392 1400
	    }
1401
 		 connectbuf[internal_connectionID]->connection_head = connectbuf[internal_connectionID]->connection_last = NULL;
1393 1402

  
1394
	    if (connectbuf[internal_connectionID]->connection_cb_2 != NULL) {
1395
		(connectbuf[internal_connectionID]->
1396
		 connection_cb_2) (internal_connectionID,
1397
				   connectbuf[internal_connectionID]->
1398
				   arg_2);
1399
	    }
1400 1403
	    // change the status
1401 1404
	    // connectbuf[internal_connectionID]->status = 2;
1402 1405

  
......
1456 1459
	    if (receive_Connection_cb != NULL)
1457 1460
		(receive_Connection_cb) (internal_connectionID, NULL);
1458 1461

  
1459

  
1460
	    if (connectbuf[internal_connectionID]->connection_cb_1 != NULL) {
1461

  
1462
		(connectbuf[internal_connectionID]->
1463
		 connection_cb_1) (internal_connectionID,
1464
				   connectbuf[internal_connectionID]->
1465
				   arg_1);
1466
	    }
1467

  
1468
	    if (connectbuf[internal_connectionID]->connection_cb_2 != NULL) {
1469
		(connectbuf[internal_connectionID]->
1470
		 connection_cb_2) (internal_connectionID,
1471
				   connectbuf[internal_connectionID]->
1472
				   arg_2);
1462
		 while(connectbuf[internal_connectionID]->connection_head != NULL) {
1463
			receive_connection_cb_list *temp;
1464
			temp = connectbuf[internal_connectionID]->connection_head;
1465
			(temp->connection_cb) (internal_connectionID, temp->arg);
1466
			connectbuf[internal_connectionID]->connection_head = temp->next;
1467
			free(temp);
1473 1468
	    }
1469
		 connectbuf[internal_connectionID]->connection_head = connectbuf[internal_connectionID]->connection_last = NULL;
1474 1470
	    // connection_establisched(connectionID_this_peer);
1475 1471
	    // printf("going here \n ");
1476 1472
	    // main_callback(0);
......
1830 1826
				bufptr += offset;
1831 1827

  
1832 1828
				// determine the fragmentsize
1829
				// TODO correct this: causes segmentation faults if data is send to a not opened connection
1833 1830
				int fragmentsize = connectbuf[local_connectionID]->pmtusize - MSGL_HEADER_SIZE;
1834 1831

  
1835 1832
				if (monitoringHeaderType == 0 || monitoringHeaderType == 1) {
transmissionHandler.h
138 138
  time_t starttime; ///< the start time
139 139
} recvdata;
140 140

  
141
typedef struct {
142
	struct receive_connection_cb_list *next;
143
	receive_connection_cb connection_cb;
144
	void *arg;
145
}receive_connection_cb_list;
146

  
141 147
/**
142 148
 * A struct with information about a connection that exist or a connection that is being established
143 149
 */
......
153 159
  int seqnr; ///< sequence number for connections that have been tried
154 160
  //struct event *timeout;
155 161
  struct timeval timeout_value; ///< the timeout value for the connection estahlishment
156
  bool internal_connect; ///< set to true if a connection to the internall address could be established 
157
  receive_connection_cb connection_cb_1; ///< A callback pointer from the type receive_connection_cb that is envoked when the connection is ready to use 
158
  void *arg_1; ///< A void pointer that is provided by the upper layer and returned with the connection callback once it is ready to use
159
  receive_connection_cb connection_cb_2; ///<  A second callback pointer from the type receive_connection_cb that is envoked when the connection is ready to use
160
  void *arg_2; ///< A void pointer that is provided by the upper layer and returned with the con\nection callback once it is ready to use 
161

  
162
  bool internal_connect; ///< set to true if a connection to the internall address could be established
163
  receive_connection_cb_list *connection_head;
164
  receive_connection_cb_list *connection_last;
162 165
} connect_data;
163 166

  
164 167
/**

Also available in: Unified diff