After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 339843 - [patch] fdsink should not handle short writes and non fatal errno
[patch] fdsink should not handle short writes and non fatal errno
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.x
Other Linux
: Normal normal
: 0.10.6
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-04-26 17:45 UTC by Philippe Rouquier
Modified: 2006-04-28 13:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (1.52 KB, patch)
2006-04-26 17:46 UTC, Philippe Rouquier
none Details | Review
updated patch (4.07 KB, patch)
2006-04-28 10:08 UTC, Wim Taymans
committed Details | Review

Description Philippe Rouquier 2006-04-26 17:45:48 UTC
Fdsink returns an error when it could not write all data of the buffer at once since we check that the number of bytes written is equal to the size of the buffer.
Now, sometimes if we use a pipe and the reader process hasn't started to read or hasn't read for some time, after a time (when the pipe buffer is full I guess) we can only write just a part of the buffer contents (it happened to me while debugging). Then, the number of bytes returned by the write != GST_BUFFER_SIZE. But that's not an error, if we check errno it's still equal to 0. Moreover when the reader process starts to read again we can write the rest of the buffer.
So what I propose is to check errno if bytes_written != GST_BUFFER_SIZE and if errno is 0, we go back to select to wait for the pipe to be ready again to accept input.
See following patch.
Comment 1 Philippe Rouquier 2006-04-26 17:46:16 UTC
Created attachment 64339 [details] [review]
proposed patch
Comment 2 Wim Taymans 2006-04-28 10:08:03 UTC
Created attachment 64460 [details] [review]
updated patch

updated patch handles EAGAIN, EINTR and short writes correctly too. Also cleans up some error cases, avoid a deadlock on bad file descriptors and uses GST_DEBUG_OBJECT.

Does this patch work fine for you?
Comment 3 Philippe Rouquier 2006-04-28 11:03:30 UTC
Great, it makes things much clearer and safer than mine.
Comment 4 Wim Taymans 2006-04-28 13:16:04 UTC
        * plugins/elements/gstfdsink.c: (gst_fd_sink_render),
        (gst_fd_sink_check_fd), (gst_fd_sink_update_fd):
        handle EAGAIN, EINTR and short writes correctly. Also clean
        up some error cases, avoid a deadlock on bad file descriptors and
        use GST_DEBUG_OBJECT.
        Fixes #339843