Bug in wsp_unit.c ?

Vjacheslav Chekushin <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization LMT
Message-ID <[email protected]>
Hi, list.

Yury Mikhienko wrote:

>  
> I changed kannel source for dumping the next information:
> 
> in wapbox.log now:
> 
> 2002-11-12 09:21:45 [1] DEBUG: WSP 227/4150: New method state REPLYING
> 2002-11-12 09:21:45 [1] DEBUG: WSP 227: New state CONNECTED
> 2002-11-12 09:21:45 [2] WARNING: WSP PDU with unknown type -1
> 2002-11-12 09:21:45 [2] WARNING: Incoming Octetstr has been dumped!!!
> 2002-11-12 09:21:45 [2] DEBUG:  Octet string at 0x89a77c8:
> 2002-11-12 09:21:45 [2] DEBUG:    len:  74
> 2002-11-12 09:21:45 [2] DEBUG:    size: 76
> 2002-11-12 09:21:45 [2] DEBUG:    immutable: 0
> 2002-11-12 09:21:45 [2] DEBUG:    data: 73 5a 12 01 10 13 30 04   sZ....0.
> 2002-11-12 09:21:45 [2] DEBUG:    data: 80 86 a0 00 04 81 92 a7   ........
> 2002-11-12 09:21:45 [2] DEBUG:    data: 60 02 82 00 02 83 05 02   `.......
> 2002-11-12 09:21:45 [2] DEBUG:    data: 84 01 80 80 83 99 81 ea   ........
> 2002-11-12 09:21:45 [2] DEBUG:    data: a9 4e 6f 6b 69 61 37 36   .Nokia76
> 2002-11-12 09:21:45 [2] DEBUG:    data: 35 30 2f 31 2e 30 20 53   50/1.0 S
> 2002-11-12 09:21:45 [2] DEBUG:    data: 79 6d 62 69 61 6e 4f 53   ymbianOS
> 2002-11-12 09:21:45 [2] DEBUG:    data: 2f 36 2e 31 20 53 65 72   /6.1 Ser
> 2002-11-12 09:21:45 [2] DEBUG:    data: 69 65 73 36 30 2f 30 2e   ies60/0.
> 2002-11-12 09:21:45 [2] DEBUG:    data: 39 00                     9.
> 2002-11-12 09:21:45 [2] DEBUG:  Octet string dump ends.
> ################################################################################
> 2002-11-12 09:21:45 [6] DEBUG: Thread 6 (gw/wap-appl.c:main_thread) terminates.
> ################################################################################
> 
> How can I solve this? May be I shall apply another SAR patch (which one?)?
> Or this problen can be solved another way?
> 
> Now I solved the problem with dirty hack the  gwthread-pthread.c:
> in:
> static void *new_thread(void *arg)
> {
>     int ret;
>     struct new_thread_args *p = arg;
> ....
>     (p->func)(p->arg);
> 
> /* Changed by me */
>    do
>    {
>      lock();
> 
>      
>      debug("gwlib.gwthread", 0, "Thread %ld (%s) terminates. ",
>           p->ti->number, p->ti->name);
>      debug("gwlib.gwthread", 0, "Try up Thread %ld (%s). ",
>           p->ti->number, p->ti->name);
>      
>      unlock();
>      
>      ret = pthread_setspecific(tsd_key, p->ti);
>      if (ret != 0) {
>         panic(ret, "gwthread-pthread: pthread_setspecific failed");
>      }
>      
>      (p->func)(p->arg);
>      
>    }while(p->ti->number==6 && !strcmp(p->ti->name,"gw/wap-appl.c:main_thread"));
> //******************************
> ....
> };
> 
> It works, but it is not a good way :((
> 
> Thanx.
> 
> 


Seems that there is bug in wsp_unit.c

static void main_thread(void *arg) {
         WAPEvent *e;
         WAPEvent *newevent;

         while (run_status == running && (e = list_consume(queue)) != NULL) {
                 wap_event_assert(e);
                 switch (e->type) {
                 case T_DUnitdata_Ind:
                         newevent = unpack_datagram(e);
/* MUST BE INSERTED  if (newevent != NULL) */
	                	dispatch_to_appl(newevent);

unpack_datagram returns NULL
(> 2002-11-12 09:21:45 [2] WARNING: WSP PDU with unknown type -1)
and dispatch NULL to wap-appl.c

So later in wap-appl.c we have (main_thread):
while (run_status == running && (ind = list_consume(queue)) != NULL) {
}

and list_consume breaks the loop and

 > 2002-11-12 09:21:45 [6] DEBUG: Thread 6 (gw/wap-appl.c:main_thread) terminates.

So any following requests will not be processed.

I think we must insert check for NULL (see above, line /* MUST BE INSERTED)

-- 
Vjacheslav Chekushin                                mailto:[email protected]
Latvian Mobile Phone Company                        http://www.lmt.lv
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.