add timeouts to all generic loaders - same timer infra.

SVN revision: 77076
This commit is contained in:
Carsten Haitzler 2012-09-26 08:07:33 +00:00
parent f80c3d9399
commit 764ddff2f8
17 changed files with 80 additions and 21 deletions

View File

@ -31,3 +31,8 @@
2012-08-30 Carsten Haitzler (The Rasterman) 2012-08-30 Carsten Haitzler (The Rasterman)
1.7.0 release 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

View File

@ -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: Changes since Evas Generic Loaders 1.2.0:
----------------------------------------- -----------------------------------------

View File

@ -1,3 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = shmfile.c shmfile.h EXTRA_DIST = shmfile.c shmfile.h timeout.c timeout.h

View File

@ -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);
}

View File

@ -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

View File

@ -17,7 +17,8 @@ bindir = $(libdir)/evas/utils
evas_image_loader_gst_SOURCES = \ evas_image_loader_gst_SOURCES = \
main.c \ 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_CFLAGS =
evas_image_loader_gst_LDADD = @GSTREAMER_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@ evas_image_loader_gst_LDADD = @GSTREAMER_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@
evas_image_loader_gst_LDFLAGS = evas_image_loader_gst_LDFLAGS =

View File

@ -5,13 +5,13 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h>
#include <gst/gst.h> #include <gst/gst.h>
#include <Eina.h> #include <Eina.h>
#include "shmfile.h" #include "shmfile.h"
#include "timeout.h"
#define DATA32 unsigned int #define DATA32 unsigned int
@ -23,8 +23,6 @@
#define D(fmt, args...) #define D(fmt, args...)
#endif #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" #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; 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)); memcpy(data, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer));
} }
static void
timeout(int val)
{
// error - timeout :(
exit(-7);
}
int int
main(int argc, char **argv) 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. timeout_init(10);
signal(SIGALRM, timeout);
alarm(TIMEOUT);
D("_gst_init_file\n"); D("_gst_init_file\n");

View File

@ -17,7 +17,8 @@ bindir = $(libdir)/evas/utils
evas_image_loader_pdf_SOURCES = \ evas_image_loader_pdf_SOURCES = \
main.cpp \ 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_CFLAGS =
evas_image_loader_pdf_LDADD = @POPPLER_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@ evas_image_loader_pdf_LDADD = @POPPLER_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@
evas_image_loader_pdf_LDFLAGS = evas_image_loader_pdf_LDFLAGS =

View File

@ -15,6 +15,7 @@
#include <Eina.h> #include <Eina.h>
#include "shmfile.h" #include "shmfile.h"
#include "timeout.h"
#define DATA32 unsigned int #define DATA32 unsigned int
@ -242,6 +243,8 @@ main(int argc, char **argv)
D("dpi....: %f\n", dpi); D("dpi....: %f\n", dpi);
D("page...: %d\n", page); D("page...: %d\n", page);
timeout_init(10);
if (!poppler_init(file, page, size_w, size_h)) if (!poppler_init(file, page, size_w, size_h))
return -1; return -1;
D("poppler_file_init done\n"); D("poppler_file_init done\n");

View File

@ -17,7 +17,8 @@ bindir = $(libdir)/evas/utils
evas_image_loader_ps_SOURCES = \ evas_image_loader_ps_SOURCES = \
main.c \ 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_CFLAGS =
evas_image_loader_ps_LDADD = @SPECTRE_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@ evas_image_loader_ps_LDADD = @SPECTRE_LIBS@ @EINA_LIBS@ @SHM_OPEN_LIBS@
evas_image_loader_ps_LDFLAGS = evas_image_loader_ps_LDFLAGS =

View File

@ -10,6 +10,7 @@
#include <Eina.h> #include <Eina.h>
#include "shmfile.h" #include "shmfile.h"
#include "timeout.h"
#define DATA32 unsigned int #define DATA32 unsigned int
@ -249,6 +250,8 @@ main(int argc, char **argv)
D("dpi....: %f\n", dpi); D("dpi....: %f\n", dpi);
D("page...: %d\n", page); D("page...: %d\n", page);
timeout_init(10);
if (!_spectre_init(file, page, size_w, size_h)) if (!_spectre_init(file, page, size_w, size_h))
return -1; return -1;
D("_spectre_init done\n"); D("_spectre_init done\n");

View File

@ -14,7 +14,10 @@ AM_CPPFLAGS = \
bin_PROGRAMS = evas_image_loader.raw bin_PROGRAMS = evas_image_loader.raw
bindir = $(libdir)/evas/utils 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_CFLAGS = @LIBRAW_CFLAGS@
evas_image_loader_raw_LDADD = @SHM_OPEN_LIBS@ @LIBRAW_LIBS@ -lm evas_image_loader_raw_LDADD = @SHM_OPEN_LIBS@ @LIBRAW_LIBS@ -lm
evas_image_loader_raw_LDFLAGS = evas_image_loader_raw_LDFLAGS =

View File

@ -9,6 +9,7 @@
#include <unistd.h> #include <unistd.h>
#include <libraw.h> #include <libraw.h>
#include "shmfile.h" #include "shmfile.h"
#include "timeout.h"
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <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 (!_raw_init(file)) return -1;
if (head_only != 0) if (head_only != 0)
{ {

View File

@ -14,7 +14,10 @@ AM_CPPFLAGS = \
bin_PROGRAMS = evas_image_loader.svg bin_PROGRAMS = evas_image_loader.svg
bindir = $(libdir)/evas/utils 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_CFLAGS = @SVG_CFLAGS@
evas_image_loader_svg_LDADD = @SVG_LIBS@ @SHM_OPEN_LIBS@ -lm evas_image_loader_svg_LDADD = @SVG_LIBS@ @SHM_OPEN_LIBS@ -lm
evas_image_loader_svg_LDFLAGS = evas_image_loader_svg_LDFLAGS =

View File

@ -3,6 +3,7 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
#include "shmfile.h" #include "shmfile.h"
#include "timeout.h"
#include <Eina.h> #include <Eina.h>
@ -181,6 +182,8 @@ int main(int argc, char **argv)
} }
} }
timeout_init(5);
if (!_svg_init(file)) return -1; if (!_svg_init(file)) return -1;
if (!read_svg_header(scale_down, dpi, size_w, size_h)) return -1; if (!read_svg_header(scale_down, dpi, size_w, size_h)) return -1;

View File

@ -16,7 +16,8 @@ bindir = $(libdir)/evas/utils
evas_image_loader_xcf_SOURCES = \ evas_image_loader_xcf_SOURCES = \
main.c pixelfuncs.c common.h \ 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_CFLAGS = @EINA_CFLAGS@
evas_image_loader_xcf_LDADD = @EINA_LIBS@ -lz -lm @SHM_OPEN_LIBS@ evas_image_loader_xcf_LDADD = @EINA_LIBS@ -lz -lm @SHM_OPEN_LIBS@
evas_image_loader_xcf_LDFLAGS = evas_image_loader_xcf_LDFLAGS =

View File

@ -47,6 +47,7 @@
*/ */
#include "common.h" #include "common.h"
#include "shmfile.h" #include "shmfile.h"
#include "timeout.h"
#define FREE(X) { free(X); X = NULL; } #define FREE(X) { free(X); X = NULL; }
@ -1693,8 +1694,12 @@ main(int argc, char **argv)
// int size_h = atoi(argv[i]); // int size_h = atoi(argv[i]);
} }
} }
timeout_init(8);
D("xcf_file_init\n"); D("xcf_file_init\n");
if (!xcf_file_init(file)) return -1; if (!xcf_file_init(file)) return -1;
D("size %i %i\n", image->width, image->height); D("size %i %i\n", image->width, image->height);
if (!head_only) if (!head_only)
{ {