1 |
vapier 14/05/03 19:51:35 |
2 |
|
3 |
Modified: mediatomb-0.12.1-thumb-cache.patch |
4 |
Added: mediatomb-0.12.1-thumbnail-locking.patch |
5 |
Log: |
6 |
Fix random crashes in thumbnail generation code. |
7 |
|
8 |
(Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key D2E96200) |
9 |
|
10 |
Revision Changes Path |
11 |
1.3 net-misc/mediatomb/files/mediatomb-0.12.1-thumb-cache.patch |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/mediatomb/files/mediatomb-0.12.1-thumb-cache.patch?rev=1.3&view=markup |
14 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/mediatomb/files/mediatomb-0.12.1-thumb-cache.patch?rev=1.3&content-type=text/plain |
15 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/mediatomb/files/mediatomb-0.12.1-thumb-cache.patch?r1=1.2&r2=1.3 |
16 |
|
17 |
Index: mediatomb-0.12.1-thumb-cache.patch |
18 |
=================================================================== |
19 |
RCS file: /var/cvsroot/gentoo-x86/net-misc/mediatomb/files/mediatomb-0.12.1-thumb-cache.patch,v |
20 |
retrieving revision 1.2 |
21 |
retrieving revision 1.3 |
22 |
diff -u -r1.2 -r1.3 |
23 |
--- mediatomb-0.12.1-thumb-cache.patch 26 Jan 2013 18:32:49 -0000 1.2 |
24 |
+++ mediatomb-0.12.1-thumb-cache.patch 3 May 2014 19:51:35 -0000 1.3 |
25 |
@@ -21,7 +21,7 @@ |
26 |
#define DEFAULT_FFMPEGTHUMBNAILER_FILMSTRIP_OVERLAY YES |
27 |
#define DEFAULT_FFMPEGTHUMBNAILER_WORKAROUND_BUGS NO |
28 |
#define DEFAULT_FFMPEGTHUMBNAILER_IMAGE_QUALITY 8 |
29 |
-+ #define DEFAULT_FFMPEGTHUMBNAILER_CACHE_DIR_ENABLED YES |
30 |
++ #define DEFAULT_FFMPEGTHUMBNAILER_CACHE_DIR_ENABLED YES |
31 |
+ #define DEFAULT_FFMPEGTHUMBNAILER_CACHE_DIR "" |
32 |
#endif |
33 |
|
34 |
@@ -88,7 +88,7 @@ |
35 |
|
36 |
+#ifdef HAVE_FFMPEGTHUMBNAILER |
37 |
+ |
38 |
-+static bool _mkdir(const char *path) |
39 |
++static int _mkdir(const char *path) |
40 |
+{ |
41 |
+ int ret = mkdir(path, 0777); |
42 |
+ |
43 |
|
44 |
|
45 |
|
46 |
1.1 net-misc/mediatomb/files/mediatomb-0.12.1-thumbnail-locking.patch |
47 |
|
48 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/mediatomb/files/mediatomb-0.12.1-thumbnail-locking.patch?rev=1.1&view=markup |
49 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/mediatomb/files/mediatomb-0.12.1-thumbnail-locking.patch?rev=1.1&content-type=text/plain |
50 |
|
51 |
Index: mediatomb-0.12.1-thumbnail-locking.patch |
52 |
=================================================================== |
53 |
if you try to generate a bunch of thumbnails at once, it can crash: |
54 |
|
55 |
Program received signal SIGABRT, Aborted. |
56 |
[Switching to Thread 0x7fdb7a6cb700 (LWP 17295)] |
57 |
0x00007fdb8031c899 in __GI_raise (sig=sig@entry=0x6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 |
58 |
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. |
59 |
(gdb) bt |
60 |
#0 0x00007fdb8031c899 in __GI_raise (sig=sig@entry=0x6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 |
61 |
#1 0x00007fdb8031de27 in __GI_abort () at abort.c:89 |
62 |
#2 0x00007fdb7f6b9222 in ff_unlock_avcodec () at /var/tmp/portage/media-video/ffmpeg-1.2.6/work/ffmpeg-1.2.6/libavcodec/utils.c:2767 |
63 |
#3 0x00007fdb7f6b9662 in avcodec_open2 (avctx=0x7fdb64032080, codec=<optimized out>, options=0x0) at /var/tmp/portage/media-video/ffmpeg-1.2.6/work/ffmpeg-1.2.6/libavcodec/utils.c:1132 |
64 |
#4 0x00007fdb81be57bb in ffmpegthumbnailer::MovieDecoder::initializeVideo (this=this@entry=0x7fdb7a6ca000) at libffmpegthumbnailer/moviedecoder.cpp:176 |
65 |
#5 0x00007fdb81be599c in ffmpegthumbnailer::MovieDecoder::initialize (this=0x7fdb7a6ca000, filename=...) at libffmpegthumbnailer/moviedecoder.cpp:86 |
66 |
#6 0x00007fdb81be92cc in ffmpegthumbnailer::VideoThumbnailer::generateThumbnail (this=this@entry=0x7fdb6402af90, videoFile=..., imageWriter=..., pAvContext=pAvContext@entry=0x0) at libffmpegthumbnailer/videothumbnailer.cpp:118 |
67 |
#7 0x00007fdb81be97b4 in ffmpegthumbnailer::VideoThumbnailer::generateThumbnail (this=this@entry=0x7fdb6402af90, videoFile=..., type=<optimized out>, type@entry=Jpeg, buffer=..., pAvContext=pAvContext@entry=0x0) at libffmpegthumbnailer/videothumbnailer.cpp:191 |
68 |
#8 0x00007fdb81bea23e in video_thumbnailer_generate_thumbnail_to_buffer (thumbnailer=<optimized out>, movie_filename=0x7fdb7003abc0 "........mp4", generated_image_data=0x7fdb64022680) at libffmpegthumbnailer/videothumbnailerc.cpp:113 |
69 |
#9 0x00000000004ebfed in FfmpegHandler::serveContent (this=this@entry=0x7fdb64020ff0, item=..., resNum=resNum@entry=0x1, data_size=data_size@entry=0x7fdb7a6caaf0) at ../src/metadata/ffmpeg_handler.cc:475 |
70 |
#10 0x00000000004e48d7 in FileRequestHandler::open (this=<optimized out>, filename=<optimized out>, info=0x7fdb7a6caaf0, mode=<optimized out>) at ../src/file_request_handler.cc:575 |
71 |
#11 0x00000000004bba74 in web_open (filename=0x7fdb640175f0 "/content/media/object_id/16634/res_id/1/rh/6/ext/file.jpg", info=0x7fdb7a6caaf0, mode=UPNP_READ) at ../src/web_callbacks.cc:198 |
72 |
#12 0x000000000052674b in process_request (Fp=<synthetic pointer>, RespInstr=0x7fdb7a6cab70, alias=0x7fdb7a6cab20, filename=0x7fdb7a6caad0, headers=0x7fdb7a6caab0, rtype=<synthetic pointer>, req=0x7fdb7a6cacd0) at ../upnp/src/genlib/net/http/webserver.c:1343 |
73 |
#13 web_server_callback (parser=0x7fdb7a6cacd0, req=0x7fdb7a6cacd0, info=0x7fdb7a6cacc0) at ../upnp/src/genlib/net/http/webserver.c:1803 |
74 |
#14 0x000000000051f29a in dispatch_request (hparser=0x7fdb7a6cacd0, info=0x7fdb7a6cacc0) at ../upnp/src/genlib/miniserver/miniserver.c:236 |
75 |
#15 handle_request (args=0x7fdb6c000c40) at ../upnp/src/genlib/miniserver/miniserver.c:339 |
76 |
#16 0x000000000052cc66 in WorkerThread (arg=0x7a80e0 <gRecvThreadPool>) at ../threadutil/src/ThreadPool.c:594 |
77 |
#17 0x00007fdb80697333 in start_thread (arg=0x7fdb7a6cb700) at pthread_create.c:309 |
78 |
#18 0x00007fdb803d226d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 |
79 |
(gdb) |
80 |
|
81 |
--- a/src/metadata/ffmpeg_handler.cc |
82 |
+++ b/src/metadata/ffmpeg_handler.cc |
83 |
@@ -311,6 +311,10 @@ void FfmpegHandler::fillMetadata(Ref<CdsItem> item) |
84 |
|
85 |
#ifdef HAVE_FFMPEGTHUMBNAILER |
86 |
|
87 |
+// The ffmpegthumbnailer code (ffmpeg?) is not threading safe. |
88 |
+// Add a lock around the usage to avoid crashing randomly. |
89 |
+static pthread_mutex_t thumb_lock; |
90 |
+ |
91 |
static int _mkdir(const char *path) |
92 |
{ |
93 |
int ret = mkdir(path, 0777); |
94 |
@@ -446,6 +450,9 @@ Ref<IOHandler> FfmpegHandler::serveContent(Ref<CdsItem> item, int resNum, off_t |
95 |
return h; |
96 |
} |
97 |
} |
98 |
+ |
99 |
+ pthread_mutex_lock(&thumb_lock); |
100 |
+ |
101 |
#ifdef FFMPEGTHUMBNAILER_OLD_API |
102 |
video_thumbnailer *th = create_thumbnailer(); |
103 |
image_data *img = create_image_data(); |
104 |
@@ -474,8 +481,11 @@ Ref<IOHandler> FfmpegHandler::serveContent(Ref<CdsItem> item, int resNum, off_t |
105 |
if (video_thumbnailer_generate_thumbnail_to_buffer(th, |
106 |
item->getLocation().c_str(), img) != 0) |
107 |
#endif // old api |
108 |
+ { |
109 |
+ pthread_mutex_unlock(&thumb_lock); |
110 |
throw _Exception(_("Could not generate thumbnail for ") + |
111 |
item->getLocation()); |
112 |
+ } |
113 |
if (cfg->getBoolOption(CFG_SERVER_EXTOPTS_FFMPEGTHUMBNAILER_CACHE_DIR_ENABLED)) { |
114 |
writeThumbnailCacheFile(item->getLocation(), |
115 |
img->image_data_ptr, img->image_data_size); |
116 |
@@ -491,6 +501,7 @@ Ref<IOHandler> FfmpegHandler::serveContent(Ref<CdsItem> item, int resNum, off_t |
117 |
video_thumbnailer_destroy_image_data(img); |
118 |
video_thumbnailer_destroy(th); |
119 |
#endif// old api |
120 |
+ pthread_mutex_unlock(&thumb_lock); |
121 |
return h; |
122 |
#else |
123 |
return nil; |