Re: postform.c in a loop seg faults

"Deshakulakarni, Chandra" <[email protected]>
Newsgroups gmane.comp.lib.libwww
Message-ID <[email protected]>
I would suggest you to initialize and terminate LIBWWW only once
instead of doing it each time in the loop.

You can have two additional functions.

lib_init()
{

    /* Create a new premptive client */
    HTProfile_newNoCacheClient("TestApp", "1.0");

    /* Need our own trace and print functions */
    HTPrint_setCallback(printer);
    HTTrace_setCallback(tracer);

    /* Get trace messages */
#if 0
    HTSetTraceMessageMask("sop");
#endif

    /* Add our own filter to update the history list */
    HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);

    /* Set the timeout for long we are going to wait for a response */
    HTHost_setEventTimeout(20000);

    HTTP_setBodyWriteDelay (250, 500);
}

lib_term()
{

    /* Terminate libwww */
    HTProfile_delete();
}

Call lib_init() before your post loop and call lib_term()
after the loop.
You need to remove the init calls in your current post() function
and term call in your terminate_handler().

Hope this helps.

-Chandra
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.