summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-09-26 08:07:33 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-09-26 08:07:33 +0000
commita066fb38cda783ccac113a62bcdbe684b283b328 (patch)
treecd755f9d72e2e94bc3915236d54dc7ceb6a4d4bc
parent76731d563970eaa5057cfa69239484cab864d074 (diff)
downloadevas_generic_loaders-a066fb38cda783ccac113a62bcdbe684b283b328.tar.gz
add timeouts to all generic loaders - same timer infra.
SVN revision: 77076
-rw-r--r--ChangeLog5
-rw-r--r--NEWS10
-rw-r--r--src/bin/common/Makefile.am2
-rw-r--r--src/bin/common/timeout.c16
-rw-r--r--src/bin/common/timeout.h14
-rw-r--r--src/bin/gst/Makefile.am3
-rw-r--r--src/bin/gst/main.c15
-rw-r--r--src/bin/pdf/Makefile.am3
-rw-r--r--src/bin/pdf/main.cpp3
-rw-r--r--src/bin/ps/Makefile.am3
-rw-r--r--src/bin/ps/main.c3
-rw-r--r--src/bin/raw/Makefile.am5
-rw-r--r--src/bin/raw/main.c3
-rw-r--r--src/bin/svg/Makefile.am5
-rw-r--r--src/bin/svg/main.c3
-rw-r--r--src/bin/xcf/Makefile.am3
-rw-r--r--src/bin/xcf/main.c5
17 files changed, 80 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 94bdc62..4e435e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,3 +31,8 @@
2012-08-30 Carsten Haitzler (The Rasterman)
1.7.0 release
+
+2012-09-26 Carsten Haitzler (The Rasterman)
+
+ * Add various alarm/signal based timeouts for all generic
+ loaders in case they get stuck
diff --git a/NEWS b/NEWS
index 7cc8c51..bc4a04c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,12 @@
-Evas Generic Loaders 1.7.0
+Evas Generic Loaders 1.8.0
+
+Changes since Evas Generic Loaders 1.7.0:
+-----------------------------------------
+
+Improvements:
+
+ * All generic loader binaries have built-in timeouts in case they
+ get stuck.
Changes since Evas Generic Loaders 1.2.0:
-----------------------------------------
diff --git a/src/bin/common/Makefile.am b/src/bin/common/Makefile.am
index 94aa560..59035f0 100644
--- a/src/bin/common/Makefile.am
+++ b/src/bin/common/Makefile.am
@@ -1,3 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in
-EXTRA_DIST = shmfile.c shmfile.h
+EXTRA_DIST = shmfile.c shmfile.h timeout.c timeout.h
diff --git a/src/bin/common/timeout.c b/src/bin/common/timeout.c
new file mode 100644
index 0000000..6d52aa9
--- /dev/null
+++ b/src/bin/common/timeout.c
@@ -0,0 +1,16 @@
+#include <unistd.h>
+#include <signal.h>
+
+static void
+_timeout(int val)
+{
+ _exit(-1);
+ if (val) return;
+}
+
+void
+timeout_init(int seconds)
+{
+ signal(SIGALRM, _timeout);
+ alarm(seconds);
+}
diff --git a/src/bin/common/timeout.h b/src/bin/common/timeout.h
new file mode 100644
index 0000000..8725627
--- /dev/null
+++ b/src/bin/common/timeout.h
@@ -0,0 +1,14 @@
+#ifndef TIMEOUT_H
+#define TIMEOUT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void timeout_init(int seconds);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/bin/gst/Makefile.am b/src/bin/gst/Makefile.am
index bbc7373..f680d64 100644
--- a/src/bin/gst/Makefile.am
+++ b/src/bin/gst/Makefile.am
@@ -17,7 +17,8 @@ bindir = $(libdir)/evas/utils
evas_image_loader_gst_SOURCES = \
main.c \
-$(top_srcdir)/src/bin/common/shmfile.c
+$(top_srcdir)/src/bin/common/shmfile.c \
+$(top_srcdir)/src/bin/common/timeout.c
evas_image_loader_gst_CFLAGS =
evas_image_loader_gst_LDADD = @GSTREAMER_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@
evas_image_loader_gst_LDFLAGS =
diff --git a/src/bin/gst/main.c b/src/bin/gst/main.c
index 18723ac..738ae3d 100644
--- a/src/bin/gst/main.c
+++ b/src/bin/gst/main.c
@@ -5,13 +5,13 @@
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
-#include <signal.h>
#include <gst/gst.h>
#include <Eina.h>
#include "shmfile.h"
+#include "timeout.h"
#define DATA32 unsigned int
@@ -23,8 +23,6 @@
#define D(fmt, args...)
#endif
-#define TIMEOUT 5
-
#define CAPS "video/x-raw-rgb,bpp=(int)32,depth=(int)32,endianness=(int)4321,red_mask=(int)0x0000ff00, green_mask=(int)0x00ff0000, blue_mask=(int)0xff000000"
static GstElement *pipeline = NULL;
@@ -172,13 +170,6 @@ _gst_load_image(int size_w, int size_h)
memcpy(data, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer));
}
-static void
-timeout(int val)
-{
- // error - timeout :(
- exit(-7);
-}
-
int
main(int argc, char **argv)
{
@@ -220,9 +211,7 @@ main(int argc, char **argv)
}
}
- // timeout: if we can't manage to get this done in TIMEOUT seconds, give up.
- signal(SIGALRM, timeout);
- alarm(TIMEOUT);
+ timeout_init(10);
D("_gst_init_file\n");
diff --git a/src/bin/pdf/Makefile.am b/src/bin/pdf/Makefile.am
index 5fc4f23..9269c1c 100644
--- a/src/bin/pdf/Makefile.am
+++ b/src/bin/pdf/Makefile.am
@@ -17,7 +17,8 @@ bindir = $(libdir)/evas/utils
evas_image_loader_pdf_SOURCES = \
main.cpp \
-$(top_srcdir)/src/bin/common/shmfile.c
+$(top_srcdir)/src/bin/common/shmfile.c \
+$(top_srcdir)/src/bin/common/timeout.c
evas_image_loader_pdf_CFLAGS =
evas_image_loader_pdf_LDADD = @POPPLER_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@
evas_image_loader_pdf_LDFLAGS =
diff --git a/src/bin/pdf/main.cpp b/src/bin/pdf/main.cpp
index b1fe1f2..cc4f532 100644
--- a/src/bin/pdf/main.cpp
+++ b/src/bin/pdf/main.cpp
@@ -15,6 +15,7 @@
#include <Eina.h>
#include "shmfile.h"
+#include "timeout.h"
#define DATA32 unsigned int
@@ -242,6 +243,8 @@ main(int argc, char **argv)
D("dpi....: %f\n", dpi);
D("page...: %d\n", page);
+ timeout_init(10);
+
if (!poppler_init(file, page, size_w, size_h))
return -1;
D("poppler_file_init done\n");
diff --git a/src/bin/ps/Makefile.am b/src/bin/ps/Makefile.am
index 95f025e..eb62cc6 100644
--- a/src/bin/ps/Makefile.am
+++ b/src/bin/ps/Makefile.am
@@ -17,7 +17,8 @@ bindir = $(libdir)/evas/utils
evas_image_loader_ps_SOURCES = \
main.c \
-$(top_srcdir)/src/bin/common/shmfile.c
+$(top_srcdir)/src/bin/common/shmfile.c \
+$(top_srcdir)/src/bin/common/timeout.c
evas_image_loader_ps_CFLAGS =
evas_image_loader_ps_LDADD = @SPECTRE_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@
evas_image_loader_ps_LDFLAGS =
diff --git a/src/bin/ps/main.c b/src/bin/ps/main.c
index a2cc8c3..39a34e6 100644
--- a/src/bin/ps/main.c
+++ b/src/bin/ps/main.c
@@ -10,6 +10,7 @@
#include <Eina.h>
#include "shmfile.h"
+#include "timeout.h"
#define DATA32 unsigned int
@@ -249,6 +250,8 @@ main(int argc, char **argv)
D("dpi....: %f\n", dpi);
D("page...: %d\n", page);
+ timeout_init(10);
+
if (!_spectre_init(file, page, size_w, size_h))
return -1;
D("_spectre_init done\n");
diff --git a/src/bin/raw/Makefile.am b/src/bin/raw/Makefile.am
index d9fa073..90d9005 100644
--- a/src/bin/raw/Makefile.am
+++ b/src/bin/raw/Makefile.am
@@ -14,7 +14,10 @@ AM_CPPFLAGS = \
bin_PROGRAMS = evas_image_loader.raw
bindir = $(libdir)/evas/utils
-evas_image_loader_raw_SOURCES = main.c $(top_srcdir)/src/bin/common/shmfile.c
+evas_image_loader_raw_SOURCES = \
+main.c \
+$(top_srcdir)/src/bin/common/shmfile.c \
+$(top_srcdir)/src/bin/common/timeout.c
evas_image_loader_raw_CFLAGS = @LIBRAW_CFLAGS@
evas_image_loader_raw_LDADD = @SHM_OPEN_LIBS@ @LIBRAW_LIBS@ -lm
evas_image_loader_raw_LDFLAGS =
diff --git a/src/bin/raw/main.c b/src/bin/raw/main.c
index 5427ee3..31626c2 100644
--- a/src/bin/raw/main.c
+++ b/src/bin/raw/main.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <libraw.h>
#include "shmfile.h"
+#include "timeout.h"
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
@@ -205,6 +206,8 @@ int main(int argc, char **argv)
}
}
+ timeout_init(4);
+
if (!_raw_init(file)) return -1;
if (head_only != 0)
{
diff --git a/src/bin/svg/Makefile.am b/src/bin/svg/Makefile.am
index 6ea0778..5366673 100644
--- a/src/bin/svg/Makefile.am
+++ b/src/bin/svg/Makefile.am
@@ -14,7 +14,10 @@ AM_CPPFLAGS = \
bin_PROGRAMS = evas_image_loader.svg
bindir = $(libdir)/evas/utils
-evas_image_loader_svg_SOURCES = main.c $(top_srcdir)/src/bin/common/shmfile.c
+evas_image_loader_svg_SOURCES = \
+main.c \
+$(top_srcdir)/src/bin/common/shmfile.c \
+$(top_srcdir)/src/bin/common/timeout.c
evas_image_loader_svg_CFLAGS = @SVG_CFLAGS@
evas_image_loader_svg_LDADD = @SVG_LIBS@ @SHM_OPEN_LIBS@ -lm
evas_image_loader_svg_LDFLAGS =
diff --git a/src/bin/svg/main.c b/src/bin/svg/main.c
index 021fc64..9a35153 100644
--- a/src/bin/svg/main.c
+++ b/src/bin/svg/main.c
@@ -3,6 +3,7 @@
#endif
#include <stdio.h>
#include "shmfile.h"
+#include "timeout.h"
#include <Eina.h>
@@ -181,6 +182,8 @@ int main(int argc, char **argv)
}
}
+ timeout_init(5);
+
if (!_svg_init(file)) return -1;
if (!read_svg_header(scale_down, dpi, size_w, size_h)) return -1;
diff --git a/src/bin/xcf/Makefile.am b/src/bin/xcf/Makefile.am
index 8d3d0b1..041e8b3 100644
--- a/src/bin/xcf/Makefile.am
+++ b/src/bin/xcf/Makefile.am
@@ -16,7 +16,8 @@ bindir = $(libdir)/evas/utils
evas_image_loader_xcf_SOURCES = \
main.c pixelfuncs.c common.h \
-$(top_srcdir)/src/bin/common/shmfile.c
+$(top_srcdir)/src/bin/common/shmfile.c \
+$(top_srcdir)/src/bin/common/timeout.c
evas_image_loader_xcf_CFLAGS = @EINA_CFLAGS@
evas_image_loader_xcf_LDADD = @EINA_LIBS@ -lz -lm @SHM_OPEN_LIBS@
evas_image_loader_xcf_LDFLAGS =
diff --git a/src/bin/xcf/main.c b/src/bin/xcf/main.c
index 084d94a..62212cf 100644
--- a/src/bin/xcf/main.c
+++ b/src/bin/xcf/main.c
@@ -47,6 +47,7 @@
*/
#include "common.h"
#include "shmfile.h"
+#include "timeout.h"
#define FREE(X) { free(X); X = NULL; }
@@ -1693,8 +1694,12 @@ main(int argc, char **argv)
// int size_h = atoi(argv[i]);
}
}
+
+ timeout_init(8);
+
D("xcf_file_init\n");
if (!xcf_file_init(file)) return -1;
+
D("size %i %i\n", image->width, image->height);
if (!head_only)
{