Re: XForms: pthreads causing crash...

From: Jeff Pierce (wd4nmq@comcast.net)
Date: Wed Apr 09 2003 - 11:40:37 EDT

  • Next message: Jean-Marc Lasgouttes: "XForms: A question about xpopup.c:handle_motion"

    # To subscribers of the xforms list from Jeff Pierce <wd4nmq@comcast.net> :

    Thanks Castagne,

    I see what you men about the problem of X not being threaded and causing
    my problems.

    Does anybody know if just using the following:
    fl_clear_browser()
    fl_addto_browser()
    are thread safe?
    Well, really just fl_addto_browser().

    It takes longer to put the new data in the browser then to get the data
    from the server. So, I could:
    deactivate browser
    clear browser
    launch thread
    thread gets data, formats it and writes it to browser,
    fl_addto_browser(), signal main thread, app, it's finished and exit,
    i.e. kill, thread.
    Once signaled by thread, main app reactivates browser.
    Is that possible?

    Castagne Nicolas wrote:
    > -> my main adress is out of order... Could you please
    > fwd my mail on the Wforms mail list for other users ?
    > Thx
    >
    > Hi Jeff !
    >
    > XForms does not have any problem with threads...
    > except that it is NOT multi thread safe.
    >
    > That means that you can use threads provided the
    > threads do not perform any call to the Xforms library.
    >
    > In your case, you should let your thread fullfil a
    > data struccture, send (somehow : mutex, message,
    > flag...) a message to the main process, and then let
    > the main process call fl_add_browser_line.
    >
    > NC
    > --- Jeff Pierce <wd4nmq@comcast.net> a écrit : > # To
    > subscribers of the xforms list from Jeff Pierce
    >
    >><wd4nmq@comcast.net> :
    >>
    >>I have an xforms app that accesses a server to get a
    >>users list that is
    >>displayed in a browser object.
    >>
    >>Ok, I have had it working for along time, but while
    >>the server is being
    >>accessed and the data fed into the browser object,
    >>all other objects
    >>freeze because of the single threaded design. Ok,
    >>lets do the serve
    >>access as a thread.
    >>
    >>Which I do using the pthread library. I test out
    >>threaded code in a
    >>non-xforms app and it runs fine.
    >>
    >>But, in the xforms app a weird thing happens.
    >>
    >>I start the app and press the button to go get the
    >>server data. Heres a
    >>flow of what the code does.
    >>1. deactivate the browser object to keep users from
    >>clicking in it.
    >>2. Change browser object background color to let
    >>user know it is
    >> updating.
    >>3. Tell the thread to go get the data.
    >>4. At this point the button callback ends and xforms
    >>should return to
    >>it's event handler ready fo another event.
    >>5. In the thread, after it has downloaded and sorted
    >>the data, it puts
    >>the data in the browser, changes the background
    >>color to normal and
    >>activates the browser object.
    >>
    >>Now here's the problem, sometimes it works
    >>perfectly. I hit the update
    >>button, the browser color changes and debug messages
    >>I have in the
    >>thread are printed. I can click on other input
    >>objects and the cursor
    >>goes there while the server thread is doing it's
    >>thing. Just what I wanted.
    >>
    >>But, most of the time, while the server is being
    >>accessed the clicked on
    >>object does NOT get the cursor, and when the server
    >>access completes,
    >>the browser data is filled in, etc, the app crashes
    >>with this error:
    >>X Error of failed request: BadWindow (invalid
    >>Window parameter)
    >> Major opcode of failed request: 38
    >>(X_QueryPointer)
    >> Resource id in failed request: 0x20000d1
    >> Serial number of failed request: 173187
    >> Current serial number in output stream: 173187
    >>
    >>Like I said sometimes it works fine, but most of the
    >>time I get this
    >>failure.
    >>
    >>
    >>--
    >>Jeff, wd4nmq
    >>wd4nmq@comcast.net
    >>http://mywebpages.comcast.net/wd4nmq
    >>
    >>_________________________________________________
    >>To unsubscribe, send the message "unsubscribe" to
    >>xforms-request@bob.usuhs.mil or see
    >>http://bob.usuhs.mil/mailserv/xforms.html
    >>XForms Home Page: http://world.std.com/~xforms
    >>List Archive:
    >>http://bob.usuhs.mil/mailserv/list-archives/
    >>Development:
    >
    > http://savannah.nongnu.org/files/?group=xforms
    >
    > ___________________________________________________________
    > Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
    > Yahoo! Mail : http://fr.mail.yahoo.com
    >

    -- 
    Jeff, wd4nmq
    wd4nmq@comcast.net
    http://mywebpages.comcast.net/wd4nmq
    

    _________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuhs.mil or see http://bob.usuhs.mil/mailserv/xforms.html XForms Home Page: http://world.std.com/~xforms List Archive: http://bob.usuhs.mil/mailserv/list-archives/ Development: http://savannah.nongnu.org/files/?group=xforms



    This archive was generated by hypermail 2b29 : Wed Apr 09 2003 - 11:46:53 EDT