[Libwebsockets] libuv loops

Andy Green andy at warmcat.com
Sat Apr 15 03:16:11 CEST 2017



On April 15, 2017 6:09:23 AM GMT+08:00, Joel Winarske <joel.winarske at gmail.com> wrote:
>Hi Andy,
>
>It happens long before the close.  I have a large chunked file, and I
>write
>each incoming response to disk.  About three writes in, it blows up.

The writes will be async in libuv, you maybe have to leave the buffers around until the libuv callback comes to say it's done (just guessing).

>Ultimately I need to cache files to a temp directory.  If lws supported
>fs
>write(), nftw(), etc I would certainly use it.

I'm not sure what the problem is... you can just add optional function ptrs to fops and fulfil them same way eg, read fops is done... lws-plat-unix.c has a read fops using posix, and lws-plat-win has a read fops using their crushed sealpup apis.  Write etc can be done the same way without libuv.

-Andy

>
>Thanks!
>Joel
>
>On Fri, Apr 14, 2017 at 2:18 PM, Andy Green <andy at warmcat.com> wrote:
>
>>
>>
>> On April 15, 2017 2:22:29 AM GMT+08:00, Joel Winarske <
>> joel.winarske at gmail.com> wrote:
>> >Hi Andy,
>> >
>> >I'm seeing some trouble with uv_fs calls.  I am using the wsi -
>context
>> >-
>> >uv loop pointer.  A few of my writes work, then I get a pointer
>> >exception
>> >in libuv uv_process_async_wakeup_req().
>> >
>> >I don't see this problem with TCP I/O via the wsi - context - uv
>loop
>> >pointer.
>> >
>> >Should I be creating a separate loop for libuv file I/O?
>>
>> Not as far as I know.
>>
>> Close handling is tricky in libuv, that'd be the first suspect.  It
>has to
>> go through two stages and the libuv loop must run to callback the
>handle
>> close part... you have to call the right apis for the libuv type or
>you
>> blow up... this isn't an lws thing but a libuv thing.
>>
>> Since you are using platform fops, which has individual native plat
>> implementations in lws, you can just not use libuv here in favour of
>the
>> native file apis; there was no libuv in the fops up to now.  Libuv is
>good
>> for when you only have one implementation, like the timers in the
>> dumb-increment plugin, that you want to be cross-platform.
>>
>> -Andy
>>
>> >Thanks,
>> >Joel
>>



More information about the Libwebsockets mailing list