Wireshark-dev: [Wireshark-dev] Issues with creation of new thread

Date Prev · Date Next · Thread Prev · Thread Next
From: harsha gampa <gampa.harsha@xxxxxxxxx>
Date: Fri, 1 May 2009 17:34:59 +0530
In wireshark , gtk/main.c code , ther's a call to gtk_main() where the main thread control is given to gtk.

I need to automate a particular user interaction� i.e. select the RTP/Stream Analysis ... from menu .

For that i have written a small code as follows :
Just before the call to gtk_main() , i have created a thread which makes a call to the callback function for RTP Stream Analysis , this as follows:


void callRTP(void *ptr)
{
while(flag)
��� {
���
��� rtp_analysis_cb(NULL,NULL);
��� sleep(5);
��� }
}
int flag=0;
int main()
{
int it1;
.........................
........................
�it1 = pthread_create( &thread1, NULL, callRTP (void*)msg);
flag=1;
gtk_main();
flag=0;
}

When i debug this program, rtp_analysis_cb function is being called but i face Segmentation Fault errors and sometimes it says Aborted...The errors are as follows:

lt-wireshark: ../../src/xcb_lock.c:77: _XGetXCBBuffer: Assertion `((int) ((xcb_req) - (dpy->request)) >= 0)' failed.

Aborted


and sometimes i get the below error:

(lt-wireshark:21151): GLib-WARNING **: g_main_context_prepare(): main loop already active in another thread

**

GLib:ERROR:/build/buildd/glib2.0-2.18.2/glib/gmain.c:2095:g_main_dispatch: assertion failed: (source)

Aborted


I request somebody to tell me, if� im not handling the thread in the right way or any other cause is creating this problem.

Thanks and Regards,
Harsha Gampa