Re: [gnet] timing problem with threads
- From: David Helder <dhelder gizmolabs org>
- To: jeanm informatik uni-leipzig de
- Cc: gnet gnetlibrary org
- Subject: Re: [gnet] timing problem with threads
- Date: 07 Aug 2003 15:09:31 -0400
GNet isn't thread-safe. Try adding a lock around accesses to the GConn.
Have you run this through gdb? Where is it seg faulting?
David
On Wed, 2003-08-06 at 15:39, Jean-Alexander Mueller wrote:
> as follow up to my own request
>
> To illustrate the problem with "gnet_conn_write", here is a patch to the
> echoclient-gconn.c file that comes with the gnet2 examples.
>
> I simply added a client function as thread. It sends (or shall) a string
> 3 times to the echo server. It segfaults when writing the second string.
> What went wrong? Again, it does it, running with valgrind :-|
>
> Greetings,
>
> JeanM.
>
>
>
> ______________________________________________________________________
>
> 34a35,54
> > GMainLoop* main_loop;
> >
> >
> > gpointer client(gpointer ptr){
> > GConn* conn = ptr;
> > GString *str;
> > guint i;
> >
> > g_main_loop_ref(main_loop);
> > while (FALSE == g_main_loop_is_running(main_loop));
> >
> > str = g_string_new("Hello World,\nGreetings from jeanm\n");
> >
> > for (i = 0; i < 3; ++i){
> > gnet_conn_write (conn, str->str, 1 + str->len);
> > g_usleep(1000000);
> > }
> > g_main_loop_unref(main_loop);
> > return NULL;
> > }
> 42d61
> < GMainLoop* main_loop;
> 73a93,95
> > /* start the producer */
> > g_thread_create(client,conn,TRUE,NULL);
> >
> 178a201
> > fprintf (stderr, "Connection close\n");
--
David Helder - dhelder gizmolabs org - http://www.gizmolabs.org/~dhelder
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]