Possible race condition with HTTP.c

"Michael Mulcahy" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi All,

During testing we are experiencing some different issues with the smsbox
when
using an sms-service and a keyword to return contents of a URL.
See end of mail for trace and a stack trace, the sms box behaviour varies,
it
throws an access violation in the debugger and panics when run outside
debugger.

Scenario:
fakesmsc - bearerbox - smsbox - IIS webserver

Note: The IIS webserver has a limit of 10 connections on it.

From debugging, it appears to be a problem in the handle_transaction
function. It occurs when the connection is broken with the WebServer.

Here are some snippets of the handle_transaction function, I have check CVS
and
it appears to be the latest source of gwlib/http.c. I left out some code
for brevity (marked with ...):

static void handle_transaction(Connection *conn, void *data)
    ...
    while (trans->state != transaction_done) {
	switch (trans->state) {
	case connecting:
	    .....
          if ((rc = send_request(trans)) == 0) {
            trans->state = reading_status;
            conn_register(trans->conn, client_fdset, handle_transaction,
                          trans);
          } else {
            list_produce(trans->caller, trans);	 /*** WHY DOES IT STAY IN
WHILE LOOP ***/
          }
          break;
	    ....
      }
    }

If send_request fails why does the driver put the transaction onto the
caller list and stay in the while loop processing the transaction?
This appears to me to be a race condition and it explains the different
behaviours I get with the SMS box.

I would suggest that if send_request fails then "goto error;" is called
as this puts the transaction onto the caller list and exits the
handle_transaction
function. This has fixed the problem for me. What do others think?

Comments are welcome?

Kindest Regards,
Michael Mulcahy.


Debug:
2003-03-28 17:56:15 [10] DEBUG: Get info about connecting socket
2003-03-28 17:56:15 [10] DEBUG: HTTP: Sending request:
2003-03-28 17:56:15 [10] DEBUG: Octet string at 00F4DD20:
2003-03-28 17:56:15 [10] DEBUG:   len:  86
2003-03-28 17:56:15 [10] DEBUG:   size: 87
2003-03-28 17:56:15 [10] DEBUG:   immutable: 0
2003-03-28 17:56:15 [10] DEBUG:   data: 47 45 54 20 68 74 74 70   GET http
2003-03-28 17:56:15 [10] DEBUG:   data: 3a 2f 2f 6b 69 65 6c 79   ://kiely
2003-03-28 17:56:15 [10] DEBUG:   data: 2f 74 65 73 74 5f 77 77   /test_ww
2003-03-28 17:56:15 [10] DEBUG:   data: 2e 61 73 70 20 48 54 54   .asp HTT
2003-03-28 17:56:15 [10] DEBUG:   data: 50 2f 31 2e 31 0d 0a 48   P/1.1..H
2003-03-28 17:56:15 [10] DEBUG:   data: 6f 73 74 3a 20 6b 69 65   ost: kie
2003-03-28 17:56:15 [10] DEBUG:   data: 6c 79 0d 0a 55 73 65 72   ly..
2003-03-28 17:56:15 [10] DEBUG: Octet string dump ends.
2003-03-28 17:56:15 [10] ERROR: Error writing 86 octets to fd 3016:
2003-03-28 17:56:15 [10] ERROR: Error writing 86 octets to fd 3016:
2003-03-28 17:56:15 [10] ERROR: Couldn't send request to
<http://kiely/test_ww.asp>
2003-03-28 17:56:15 [5] DEBUG: message length 49, sending 1 messages
2003-03-28 17:56:15 [10] PANIC: Internal error: Invalid HTTPServer state.


Stack Trace:
conn_get_connect_result(Connection * 0x00000000) line 534 + 3 bytes
handle_transaction(Connection * 0x00fb7750, void * 0x01c7b210) line 1134 +
15 bytes
poll_callback(int 0x00003d1c, int 0x00000004, void * 0x00fb7750) line 863 +
19 bytes
poller(void * 0x01c79640) line 324 + 55 bytes


ANAM Wireless Internet Solutions
http://www.anam.com mailto:[email protected]
+353 1 284 7555
Castle Yard, Saint Patrick's Road, Dalkey, County Dublin, Ireland
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.