[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: callback userdata in multithreaded apps


i solved the issue by using a mutex.  Set before bind accept and release after auth success/fail.  Perhaps not the most efficient but its gets me moving again.

-Eric

> On Oct 12, 2017, at 2:17 PM, Eric Bentley <eric@xxxxxxxxxxxxxxxx> wrote:
> 
> I’m looking at the examples/samplesshd-cb.c (https://git.libssh.org/projects/libssh.git/tree/examples/samplesshd-cb.c <https://git.libssh.org/projects/libssh.git/tree/examples/samplesshd-cb.c>) example and am trying to use it as a model for a multithread version that would be able to accept multiple simultaneous connections.  
> 
> The problem is that the callback userdata member is shared amongst all threads.  I don’t want to have to reinvent the wheel here so is there an existing way to deal with this in multithread solutions?
> 
> If not, I’m thinking of either passing in a userdata struct which includes a mutex, or adding something to the session structure.
> 
> Thanks in advance.
> 
> -Eric


References:
callback userdata in multithreaded appsEric Bentley <eric@xxxxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org