[Ur] request for review of file save ffi extension

Orchidaceae Phalaenopsis orchid.hybrid at gmail.com
Sun Oct 25 13:48:48 EDT 2015


Thank you kindly!

I've fixed the fclose bug.

On Sun, Oct 25, 2015 at 2:42 PM, Adam Chlipala <adamc at csail.mit.edu> wrote:
> This code looks basically OK to me.  I don't think it maintains the true
> transactional semantics, but you may be OK with that.  For example, if
> multiple transactions are writing multiple files, and some filenames are
> being written by multiple transactions, then disk states can be observed
> that aren't consistent with some serial order of transactions.
>
> The commit handler doesn't seem to close the file handle in exceptional
> cases, which probably leads to a resource leak.
>
> Minor point: I suggest strdup() as a faster way to make a string copy, vs.
> the malloc() and strcpy() you have now.
>
>
> On 10/25/2015 10:34 AM, Orchidaceae Phalaenopsis wrote:
>>
>> Hello,
>>
>> I've modified the file upload demo slightly to save the file to the
>> hard disk instead of echoing it back:
>>
>> * https://github.com/orchid-hybrid/urweb-file/tree/master
>>
>> In particular I have used ffi handlers to make saving the file a
>> transactional operation. I've been very careful to follow the manual
>> on correct use of the ffi but I would really appreciate if people
>> would look over this and comment on whether it's correct or not:
>>
>> * https://github.com/orchid-hybrid/urweb-file/blob/master/file.c
>>
>> I'm worried about not freeing memory that needed to be, double frees,
>> using memory after free, things like that.
>>
>> (N.B. This is step 1 of a larger project, I need to save files to a
>> folder so that they can be processed by some unix tools before the
>> results are published)
>>
>> Thank you very much!
>
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur



More information about the Ur mailing list