errno=0 How to debug/avoid problem.-- - Unix

This is a discussion on errno=0 How to debug/avoid problem.-- - Unix ; Hi, Brief Description, ======Logic Tcp Client program======== Main Will create N Thread. ==============Each Thread Will======= For Loop 50 Times......Below. currently> {For loop start 1. Open Connection. 2. Send Request Packet. write 3. Recieve Reply Packet. 4. Close Connection. }//For loop ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: errno=0 How to debug/avoid problem.--

  1. errno=0 How to debug/avoid problem.--

    Hi,


    Brief Description,
    ======Logic Tcp Client program========
    Main Will create N Thread.

    ==============Each Thread Will=======
    For Loop 50 Times......Below. <10 is hardcoded
    currently>
    {For loop start
    1. Open Connection.
    2. Send Request Packet. write
    3. Recieve Reply Packet.
    4. Close Connection.
    }//For loop end
    Thread_exit



    While running above program wtih multiple threads In Few
    cases we got

    errno=0,
    Error=Error 0, strerror of errno
    return Value of read =-1

    Unable to find any useful stuff.any suggestion how to debug and/or
    avoid this ?


    -Raxit


  2. Re: errno=0 How to debug/avoid problem.--

    Sheth Raxit writes:

    > While running above program wtih multiple threads In Few
    > cases we got
    >
    > errno=0,
    > Error=Error 0, strerror of errno
    > return Value of read =-1
    >
    > Unable to find any useful stuff.any suggestion how to debug and/or
    > avoid this ?


    You didn't say which OS/compiler you used, I am guessing Solaris or AIX.

    The most likely cause is that you didn't build your program correctly
    for multi-threaded execution, and so your threads reference the
    "global errno", instead of thread-local one.

    Don't do this:

    cc -c foo.c && cc foo.o -lpthread

    Do this instead:

    cc -mt -c foo.c && cc -mt foo.o # Solaris
    xlc_r -c foo.c && xlc_r foo.o # AIX

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: errno=0 How to debug/avoid problem.--

    On Oct 31, 7:47 pm, Paul Pluzhnikov
    wrote:
    > Sheth Raxit writes:
    > > While running above program wtih multiple threads In Few
    > > cases we got

    >
    > > errno=0,
    > > Error=Error 0, strerror of errno
    > > return Value of read =-1

    >
    > > Unable to find any useful stuff.any suggestion how to debug and/or
    > > avoid this ?

    >
    > You didn't say which OS/compiler you used, I am guessing Solaris or AIX.
    >
    > The most likely cause is that you didn't build your program correctly
    > for multi-threaded execution, and so your threads reference the
    > "global errno", instead of thread-local one.
    >
    > Don't do this:
    >
    > cc -c foo.c && cc foo.o -lpthread


    How Can I Do this Dumb Mistake ?
    Yes, I did forgot to add proper Thread safety option in gcc. !
    only advice to myself is Don't Hurry. !

    Thanx
    >
    > Do this instead:
    >
    > cc -mt -c foo.c && cc -mt foo.o # Solaris
    > xlc_r -c foo.c && xlc_r foo.o # AIX
    >
    > Cheers,
    > --
    > In order to understand recursion you must first understand recursion.
    > Remove /-nsp/ for email.


    -Raxit


+ Reply to Thread