~ubuntu-branches/ubuntu/trusty/curl/trusty

« back to all changes in this revision

Viewing changes to lib/easy.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2013-12-20 09:13:22 UTC
  • mfrom: (3.4.44 sid)
  • Revision ID: package-import@ubuntu.com-20131220091322-lqk9xf5wba7vsyfh
Tags: 7.34.0-1ubuntu1
* Resynchronize on Debian, remaining changes
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from binary package Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.
* Dropped undocumented Build-Depends change to automake1.9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include <sys/param.h>
51
51
#endif
52
52
 
53
 
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SIGACTION) && defined(USE_OPENSSL)
54
 
#define SIGPIPE_IGNORE 1
55
 
#include <signal.h>
56
 
#endif
57
 
 
58
53
#include "strequal.h"
59
54
#include "urldata.h"
60
55
#include <curl/curl.h>
78
73
#include "warnless.h"
79
74
#include "conncache.h"
80
75
#include "multiif.h"
 
76
#include "sigpipe.h"
81
77
 
82
78
#define _MPRINTF_REPLACE /* use our functions only */
83
79
#include <curl/mprintf.h>
85
81
/* The last #include file should be: */
86
82
#include "memdebug.h"
87
83
 
88
 
#ifdef SIGPIPE_IGNORE
89
 
struct sigpipe_ignore {
90
 
  struct sigaction old_pipe_act;
91
 
  bool no_signal;
92
 
};
93
 
 
94
 
#define SIGPIPE_VARIABLE(x) struct sigpipe_ignore x
95
 
 
96
 
/*
97
 
 * sigpipe_ignore() makes sure we ignore SIGPIPE while running libcurl
98
 
 * internals, and then sigpipe_restore() will restore the situation when we
99
 
 * return from libcurl again.
100
 
 */
101
 
static void sigpipe_ignore(struct SessionHandle *data,
102
 
                           struct sigpipe_ignore *ig)
103
 
{
104
 
  /* get a local copy of no_signal because the SessionHandle might not be
105
 
     around when we restore */
106
 
  ig->no_signal = data->set.no_signal;
107
 
  if(!data->set.no_signal) {
108
 
    struct sigaction action;
109
 
    /* first, extract the existing situation */
110
 
    memset(&ig->old_pipe_act, 0, sizeof(struct sigaction));
111
 
    sigaction(SIGPIPE, NULL, &ig->old_pipe_act);
112
 
    action = ig->old_pipe_act;
113
 
    /* ignore this signal */
114
 
    action.sa_handler = SIG_IGN;
115
 
    sigaction(SIGPIPE, &action, NULL);
116
 
  }
117
 
}
118
 
 
119
 
/*
120
 
 * sigpipe_restore() puts back the outside world's opinion of signal handler
121
 
 * and SIGPIPE handling. It MUST only be called after a corresponding
122
 
 * sigpipe_ignore() was used.
123
 
 */
124
 
static void sigpipe_restore(struct sigpipe_ignore *ig)
125
 
{
126
 
  if(!ig->no_signal)
127
 
    /* restore the outside state */
128
 
    sigaction(SIGPIPE, &ig->old_pipe_act, NULL);
129
 
}
130
 
 
131
 
#else
132
 
/* for systems without sigaction */
133
 
#define sigpipe_ignore(x,y) Curl_nop_stmt
134
 
#define sigpipe_restore(x)  Curl_nop_stmt
135
 
#define SIGPIPE_VARIABLE(x)
136
 
#endif
137
 
 
138
84
/* win32_cleanup() is for win32 socket cleanup functionality, the opposite
139
85
   of win32_init() */
140
86
static void win32_cleanup(void)