On 06/18/2015 10:35 AM, Malahal Naineni wrote:
> Soumya Koduri [skod...@redhat.com] wrote:
>> Right. But even on success, "retval" need not be set until the
>> thread exits with a value other than NULL.
>>
>>  From the manpage,
>>>>>
>>         If retval is not NULL, then pthread_join() copies the exit
>> status of the target thread (i.e., the value that the target thread
>> supplied to pthread_exit(3)) into the location pointed to by
>> *retval. If the target thread was canceled, then PTHREAD_CANCELED is
>> placed in *retval.
>> <<<<<
>
> The retval that the man page refers there is actually passed in arg to
> pthread_join. This is never null in your case as you pass &retval.
>
>> So to check if the retval is not NULL or if thread in fact had exit
>> with a value, had declared it as pointer.
>
> You don't need to declare it as a pointer if your thread exits with an
> integer.
>
>> No at present, we do not see these messages as UP_THREAD returns
>> NULL on exit.
>
> The only way the existing code makes sense is if your upcall thread
> exits with a pointer. An integer exit should cause the code crash. Are
> you really intending to return a valid pointer from your upcall thread
> rather than an integer?
>
I thought pthread_exit() always returns a pointer which gets assigned to 
retval of pthread_join(). I assume this is the flow -->

pthread_join (thread, void **retval_join)

pthread_exit (void *retval_exit)

On exit,
*retval_join = retval_exit;

I tried a sample program as per your suggestion.

int ret1;
pthread_join (thread, (void **)&ret1);

int ret2 = 1;
pthread_exit (&ret2);

After pthread_join, ret1 has address of ret2 instead of its value.
i.e, this led to
ret1 = &ret2;

Please correct me if I am missing something.

Thanks,
Soumya

> Regards, Malahal.
>

------------------------------------------------------------------------------
_______________________________________________
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel

Reply via email to