[sheepdog] [disscuss] Design of Libsheepdog

Joseph Glanville joseph at cloudscaling.com
Mon Jul 1 08:50:33 CEST 2013


I would prefer if we didn't use threads and instead left the
concurrency/parallelism to the caller.
In particular you should be able to operate sheepdog in non-blocking
mode and achieve concurrency via an eventloop like libev/libuv without
having to involve threads.
Or you can use threads, or if you have a really high performance
application you can use multiple event loops in multiple threads.
This does mean making use of callbacks or events of some kind. We
already use signalfd/eventfd but it depends on how cross platform this
should be.

A good example of this is the libpq postgres library, it's very cross
platform and operates in a non-blocking fashion. It's callback based
which can be a little nasty but it's on a whole pretty good
considering it's age.
Because of this there exist many wrappers for it, both threaded and evented.

Joseph.

On Mon, Jul 1, 2013 at 12:05 PM, Liu Yuan <namei.unix at gmail.com> wrote:
> On 07/01/2013 09:58 AM, Kai Zhang wrote:
>>
>>
>> On Jul 1, 2013, at 7:29 AM, MORITA Kazutaka <morita.kazutaka at gmail.com
>> <mailto:morita.kazutaka at gmail.com>> wrote:
>>
>>> At Sun, 30 Jun 2013 17:29:28 +0800,
>>> Kai Zhang wrote:
>>>>
>>>>
>>>> On Jun 27, 2013, at 11:34 AM, MORITA Kazutaka
>>>> <morita.kazutaka at lab.ntt.co.jp
>>>> <mailto:morita.kazutaka at lab.ntt.co.jp>> wrote:
>>>>
>>>>>>
>>>>>> /* connection */
>>>>>> int sd_init(char *addr, const sd_t *sd);
>>>>>
>>>>>
>>>>> I think the syntax of addr needs discussion:
>>>>> - How to specify a port number?
>>>>> - How to connect to a unix domain socket?
>>>>>
>>>>>
>>>>
>>>> I think we can use a unified form: "ip:port".
>>>>
>>>> If the ip is local, sd_init() will try to use unix domain socket.
>>>
>>>
>>> Do you mean "localhost:<unix domain socket path>"?
>>
>>
>> Well, what I meant is that user don't need to care about unix domain
>> socket.
>> They always use string "x.x.x.x:nnnn" as the argument.
>> However, libsheepdog can detect whether x.x.x.x is a local ip.
>> It it is, I think we can predicate a unix domain socket path based on
>> the ip and port number.
>> For example, we can have a rule that if a sheep is listening on
>> 127.0.0.1:1234,
>> it's unix domain socket path should be something like
>> /tmp/sheepdog/127_0_0_1-1234.sock
>>
>
> char * string can't both mean 'ip:port' and unix socket path? I think it is
> very easy to detect whether it is IP format or unix socket path by strchr(3)
> ":". just don't allow ":" for path. Or we can prefix the string, like
> tcp://ip:port, unix://path.
>
> Thanks,
> Yuan
>
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list