|
@@ -47,7 +47,7 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
47
|
47
|
if(sigemptyset(&emptyset))
|
48
|
48
|
{
|
49
|
49
|
err = errno;
|
50
|
|
- syslog( LOG_ALERT, "sigemptyset fails in piper : %s",
|
|
50
|
+ pyfcgi_log( LOG_ALERT, "sigemptyset fails in piper : %s",
|
51
|
51
|
strerror(err));
|
52
|
52
|
exit(err);
|
53
|
53
|
}
|
|
@@ -61,12 +61,12 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
61
|
61
|
if( !(piper_stack = malloc(PIPER_STACK_SZ)) )
|
62
|
62
|
{
|
63
|
63
|
err = errno;
|
64
|
|
- syslog(LOG_ALERT, "Error while allocating piper stack : %s",
|
|
64
|
+ pyfcgi_log(LOG_ALERT, "Error while allocating piper stack : %s",
|
65
|
65
|
strerror(err));
|
66
|
66
|
exit(err);
|
67
|
67
|
}
|
68
|
68
|
|
69
|
|
- syslog( LOG_INFO,
|
|
69
|
+ pyfcgi_log( LOG_INFO,
|
70
|
70
|
"Worker %d started", wrk_id);
|
71
|
71
|
|
72
|
72
|
update_python_path(); // add cwd to python path
|
|
@@ -76,14 +76,14 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
76
|
76
|
piper_args.pystderr = pipe_err[0];
|
77
|
77
|
|
78
|
78
|
fetch_pyflush(&pystdout_flush, &pystderr_flush);
|
79
|
|
- syslog( LOG_INFO,
|
|
79
|
+ pyfcgi_log( LOG_INFO,
|
80
|
80
|
"Worker[%d] Python started", wrk_id);
|
81
|
81
|
|
82
|
82
|
//importing os
|
83
|
83
|
py_osmod = PyImport_ImportModule("os");
|
84
|
84
|
if(!py_osmod)
|
85
|
85
|
{
|
86
|
|
- syslog(LOG_ALERT, "Unable to import os module");
|
|
86
|
+ pyfcgi_log(LOG_ALERT, "Unable to import os module");
|
87
|
87
|
log_expt(LOG_ALERT);
|
88
|
88
|
Py_Exit(EXIT_PYERR);
|
89
|
89
|
}
|
|
@@ -91,7 +91,7 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
91
|
91
|
// loading module
|
92
|
92
|
entry_fun = import_entrypoint(py_entrypoint);
|
93
|
93
|
|
94
|
|
- syslog( LOG_INFO,
|
|
94
|
+ pyfcgi_log( LOG_INFO,
|
95
|
95
|
"Worker[%d] Waiting request with %s.%s()", wrk_id,
|
96
|
96
|
py_entrypoint, PYENTRY_FUNNAME);
|
97
|
97
|
|
|
@@ -100,7 +100,7 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
100
|
100
|
if(semop(semid, &sop, 1) < 0)
|
101
|
101
|
{
|
102
|
102
|
err = errno;
|
103
|
|
- syslog(LOG_ERR,
|
|
103
|
+ pyfcgi_log(LOG_ERR,
|
104
|
104
|
"Worker[%d] error incrementing the semaphore : %s",
|
105
|
105
|
wrk_id, strerror(err));
|
106
|
106
|
}
|
|
@@ -108,7 +108,7 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
108
|
108
|
if(pipe(pipe_ctl) == -1)
|
109
|
109
|
{
|
110
|
110
|
err = errno;
|
111
|
|
- syslog(LOG_ALERT,
|
|
111
|
+ pyfcgi_log(LOG_ALERT,
|
112
|
112
|
"Worker[%d] Pipe fails for piper ctl : %s",
|
113
|
113
|
wrk_id, strerror(err));
|
114
|
114
|
exit(err);
|
|
@@ -123,14 +123,14 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
123
|
123
|
if(semop(semid, &sop, 1) < 0)
|
124
|
124
|
{
|
125
|
125
|
err = errno;
|
126
|
|
- syslog(LOG_ERR,
|
|
126
|
+ pyfcgi_log(LOG_ERR,
|
127
|
127
|
"Worker[%d] error decrementing the semaphore : %s",
|
128
|
128
|
wrk_id, strerror(err));
|
129
|
129
|
}
|
130
|
130
|
|
131
|
131
|
count++;
|
132
|
132
|
/*
|
133
|
|
- syslog( LOG_INFO,
|
|
133
|
+ pyfcgi_log( LOG_INFO,
|
134
|
134
|
"Worker[%d] request %d", wrk_id, count);
|
135
|
135
|
*/
|
136
|
136
|
piper_args.out = out_stream;
|
|
@@ -150,7 +150,7 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
150
|
150
|
if(pid < 0)
|
151
|
151
|
{
|
152
|
152
|
err = errno;
|
153
|
|
- syslog(LOG_ALERT,
|
|
153
|
+ pyfcgi_log(LOG_ALERT,
|
154
|
154
|
"Worker[%d] req #%d Fork failed for piper : %s",
|
155
|
155
|
wrk_id, count, strerror(err));
|
156
|
156
|
exit(err);
|
|
@@ -175,7 +175,7 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
175
|
175
|
else
|
176
|
176
|
{
|
177
|
177
|
/*
|
178
|
|
- syslog(LOG_DEBUG, "Worker[%d] request %d funcall [OK]",
|
|
178
|
+ pyfcgi_log(LOG_DEBUG, "Worker[%d] request %d funcall [OK]",
|
179
|
179
|
wrk_id, count);
|
180
|
180
|
*/
|
181
|
181
|
}
|
|
@@ -189,23 +189,23 @@ int work(char* py_entrypoint, int wrk_id, int semid, int max_reqs)
|
189
|
189
|
kill(pid, WPIPER_SIG); //indicate child python call ended
|
190
|
190
|
/*
|
191
|
191
|
gettimeofday(&stop, NULL);
|
192
|
|
-syslog(LOG_DEBUG, "W%dR%dtimer KIL %ld.%06ld us", wrk_id, count, stop.tv_sec - start.tv_sec, stop.tv_usec - start.tv_usec);
|
|
192
|
+pyfcgi_log(LOG_DEBUG, "W%dR%dtimer KIL %ld.%06ld us", wrk_id, count, stop.tv_sec - start.tv_sec, stop.tv_usec - start.tv_usec);
|
193
|
193
|
*/
|
194
|
194
|
waitpid(pid, &piper_status, 0);
|
195
|
195
|
/*
|
196
|
196
|
gettimeofday(&stop, NULL);
|
197
|
|
-syslog(LOG_DEBUG, "W%dR%dtimer W8 %ld.%06ld us", wrk_id, count, stop.tv_sec - start.tv_sec, stop.tv_usec - start.tv_usec);
|
|
197
|
+pyfcgi_log(LOG_DEBUG, "W%dR%dtimer W8 %ld.%06ld us", wrk_id, count, stop.tv_sec - start.tv_sec, stop.tv_usec - start.tv_usec);
|
198
|
198
|
*/
|
199
|
199
|
if(WIFSIGNALED(piper_status))
|
200
|
200
|
{
|
201
|
|
- syslog(LOG_ERR,
|
|
201
|
+ pyfcgi_log(LOG_ERR,
|
202
|
202
|
"Woker[%d] req #%d piper terminated by sig %d",
|
203
|
203
|
wrk_id, count, WTERMSIG(piper_status));
|
204
|
204
|
exit(40);
|
205
|
205
|
}
|
206
|
206
|
else if(WEXITSTATUS(piper_status))
|
207
|
207
|
{
|
208
|
|
- syslog(LOG_ERR,
|
|
208
|
+ pyfcgi_log(LOG_ERR,
|
209
|
209
|
"Woker[%d] req #%d piper exited with error status %d",
|
210
|
210
|
wrk_id, count, WEXITSTATUS(piper_status));
|
211
|
211
|
exit(41);
|
|
@@ -221,7 +221,7 @@ syslog(LOG_DEBUG, "W%dR%dtimer W8 %ld.%06ld us", wrk_id, count, stop.tv_sec - s
|
221
|
221
|
if(semop(semid, &sop, 1) < 0)
|
222
|
222
|
{
|
223
|
223
|
err = errno;
|
224
|
|
- syslog(LOG_ERR,
|
|
224
|
+ pyfcgi_log(LOG_ERR,
|
225
|
225
|
"Worker[%d] error incrementing the semaphore : %s",
|
226
|
226
|
wrk_id, strerror(err));
|
227
|
227
|
}
|
|
@@ -233,7 +233,7 @@ syslog(LOG_DEBUG, "W%dR%dtimer W8 %ld.%06ld us", wrk_id, count, stop.tv_sec - s
|
233
|
233
|
stop.tv_usec += 1000000;
|
234
|
234
|
stop.tv_sec -= 1;
|
235
|
235
|
}
|
236
|
|
- syslog(LOG_DEBUG, "Worker[%d] request %d END [OK] %lu bytes in %ld.%06lds",
|
|
236
|
+ pyfcgi_log(LOG_DEBUG, "Worker[%d] request %d END [OK] %lu bytes in %ld.%06lds",
|
237
|
237
|
wrk_id, count, rep_sz, stop.tv_sec, stop.tv_usec);
|
238
|
238
|
}
|
239
|
239
|
free(piper_stack);
|
|
@@ -269,14 +269,14 @@ int worker_piper(void *ptr)
|
269
|
269
|
if(sigaction(WPIPER_SIG, act, NULL))
|
270
|
270
|
{
|
271
|
271
|
err = errno;
|
272
|
|
- syslog( LOG_ALERT, "Unable to sigaction in piper : %s",
|
|
272
|
+ pyfcgi_log( LOG_ALERT, "Unable to sigaction in piper : %s",
|
273
|
273
|
strerror(err));
|
274
|
274
|
exit(err);
|
275
|
275
|
}
|
276
|
276
|
write(ctl_pipe, " ", 1);
|
277
|
277
|
|
278
|
278
|
|
279
|
|
- //syslog(LOG_DEBUG, "Worker[%d] req #%d piper", wrk_id, req_id);
|
|
279
|
+ //pyfcgi_log(LOG_DEBUG, "Worker[%d] req #%d piper", wrk_id, req_id);
|
280
|
280
|
|
281
|
281
|
fds[0].fd = pystderr;
|
282
|
282
|
fds[1].fd = pystdout;
|
|
@@ -290,7 +290,7 @@ int worker_piper(void *ptr)
|
290
|
290
|
while(cont)
|
291
|
291
|
{
|
292
|
292
|
poll_ret = poll(fds, nfds, 0);
|
293
|
|
-//syslog(LOG_DEBUG, "Worker[%d] req #%d poll_ret = %d", wrk_id, req_id, poll_ret);
|
|
293
|
+//pyfcgi_log(LOG_DEBUG, "Worker[%d] req #%d poll_ret = %d", wrk_id, req_id, poll_ret);
|
294
|
294
|
if(poll_ret < 0)
|
295
|
295
|
{
|
296
|
296
|
err = errno;
|
|
@@ -298,7 +298,7 @@ int worker_piper(void *ptr)
|
298
|
298
|
{
|
299
|
299
|
continue;
|
300
|
300
|
}
|
301
|
|
- syslog( LOG_WARNING, "Poll error : %s",
|
|
301
|
+ pyfcgi_log( LOG_WARNING, "Poll error : %s",
|
302
|
302
|
strerror(err));
|
303
|
303
|
fds[0].revents = fds[1].revents = 0;
|
304
|
304
|
continue;
|
|
@@ -311,19 +311,19 @@ int worker_piper(void *ptr)
|
311
|
311
|
if(poll_ret && (revents = fds[1].revents))
|
312
|
312
|
{
|
313
|
313
|
/*
|
314
|
|
- syslog(LOG_DEBUG, "Worker[%d] req #%d STDOUT evt !",
|
|
314
|
+ pyfcgi_log(LOG_DEBUG, "Worker[%d] req #%d STDOUT evt !",
|
315
|
315
|
wrk_id, req_id);
|
316
|
316
|
*/
|
317
|
317
|
poll_ret--;
|
318
|
318
|
if(revents & POLLIN)
|
319
|
319
|
{
|
320
|
320
|
/*
|
321
|
|
- syslog(LOG_DEBUG, "Worker[%d] req #%d POLLIN STDOUT !",
|
|
321
|
+ pyfcgi_log(LOG_DEBUG, "Worker[%d] req #%d POLLIN STDOUT !",
|
322
|
322
|
wrk_id, req_id);
|
323
|
323
|
*/
|
324
|
324
|
ret = read(pystdout, buf, PIPE_BUF);
|
325
|
325
|
/*
|
326
|
|
- syslog(LOG_DEBUG, "Worker[%d] req #%d read(stdout) ret %d",
|
|
326
|
+ pyfcgi_log(LOG_DEBUG, "Worker[%d] req #%d read(stdout) ret %d",
|
327
|
327
|
wrk_id, req_id, ret);
|
328
|
328
|
*/
|
329
|
329
|
if(ret < 0)
|
|
@@ -333,7 +333,7 @@ int worker_piper(void *ptr)
|
333
|
333
|
{
|
334
|
334
|
continue;
|
335
|
335
|
}
|
336
|
|
- syslog( LOG_ERR,
|
|
336
|
+ pyfcgi_log( LOG_ERR,
|
337
|
337
|
"Error reading python stdout : %s",
|
338
|
338
|
strerror(err));
|
339
|
339
|
exit(err);
|
|
@@ -355,13 +355,13 @@ int worker_piper(void *ptr)
|
355
|
355
|
if(poll_ret && (revents = fds[0].revents))
|
356
|
356
|
{
|
357
|
357
|
/*
|
358
|
|
- syslog(LOG_DEBUG, "Worker[%d] req #%d STDERR evt !",
|
|
358
|
+ pyfcgi_log(LOG_DEBUG, "Worker[%d] req #%d STDERR evt !",
|
359
|
359
|
wrk_id, req_id);
|
360
|
360
|
*/
|
361
|
361
|
if(revents & POLLIN)
|
362
|
362
|
{
|
363
|
363
|
/*
|
364
|
|
- syslog(LOG_DEBUG, "Worker[%d] req #%d POLLIN STDERR !",
|
|
364
|
+ pyfcgi_log(LOG_DEBUG, "Worker[%d] req #%d POLLIN STDERR !",
|
365
|
365
|
wrk_id, req_id);
|
366
|
366
|
*/
|
367
|
367
|
while(1)
|
|
@@ -374,13 +374,13 @@ int worker_piper(void *ptr)
|
374
|
374
|
{
|
375
|
375
|
continue;
|
376
|
376
|
}
|
377
|
|
- syslog( LOG_ERR,
|
|
377
|
+ pyfcgi_log( LOG_ERR,
|
378
|
378
|
"Error reading python stdout : %s",
|
379
|
379
|
strerror(err));
|
380
|
380
|
exit(err);
|
381
|
381
|
}
|
382
|
382
|
buf[ret] = '\0';
|
383
|
|
- syslog(LOG_ERR,
|
|
383
|
+ pyfcgi_log(LOG_ERR,
|
384
|
384
|
"Worker[%d] Python error : %s",
|
385
|
385
|
wrk_id, buf);
|
386
|
386
|
break;
|
|
@@ -391,7 +391,7 @@ int worker_piper(void *ptr)
|
391
|
391
|
fds[0].revents = fds[1].revents = 0;
|
392
|
392
|
}
|
393
|
393
|
/*
|
394
|
|
- syslog(LOG_DEBUG, "Worker[%d] req #%d piper exiting...",
|
|
394
|
+ pyfcgi_log(LOG_DEBUG, "Worker[%d] req #%d piper exiting...",
|
395
|
395
|
wrk_id, req_id);
|
396
|
396
|
*/
|
397
|
397
|
if(!closed)
|
|
@@ -406,7 +406,7 @@ int worker_piper(void *ptr)
|
406
|
406
|
void worker_piper_sighandler(int signum)
|
407
|
407
|
{
|
408
|
408
|
worker_piper_sigrcv = 1;
|
409
|
|
- //syslog(LOG_DEBUG, "SIG");
|
|
409
|
+ //pyfcgi_log(LOG_DEBUG, "SIG");
|
410
|
410
|
}
|
411
|
411
|
|
412
|
412
|
int ctl_get_rep_sz(int ctl_pipe, size_t* rep_sz)
|
|
@@ -421,25 +421,25 @@ int ctl_get_rep_sz(int ctl_pipe, size_t* rep_sz)
|
421
|
421
|
if( (ret = poll(&fds, 1, 0)) < 0)
|
422
|
422
|
{
|
423
|
423
|
err = errno;
|
424
|
|
- syslog(LOG_ERR, "Failed to poll ctl pipe : %s",
|
|
424
|
+ pyfcgi_log(LOG_ERR, "Failed to poll ctl pipe : %s",
|
425
|
425
|
strerror(err));
|
426
|
426
|
return -1;
|
427
|
427
|
}
|
428
|
428
|
if(!ret)
|
429
|
429
|
{
|
430
|
|
- syslog(LOG_ERR, "No data in ctl pipe for rep_sz...");
|
|
430
|
+ pyfcgi_log(LOG_ERR, "No data in ctl pipe for rep_sz...");
|
431
|
431
|
return -1;
|
432
|
432
|
}
|
433
|
433
|
ret = read(ctl_pipe, rep_sz, sizeof(size_t));
|
434
|
434
|
if(ret < 0)
|
435
|
435
|
{
|
436
|
|
- syslog(LOG_ERR, "Error reading ctl pipe : %s",
|
|
436
|
+ pyfcgi_log(LOG_ERR, "Error reading ctl pipe : %s",
|
437
|
437
|
strerror(errno));
|
438
|
438
|
return -1;
|
439
|
439
|
}
|
440
|
440
|
if(ret < sizeof(size_t))
|
441
|
441
|
{
|
442
|
|
- syslog(LOG_ERR, "Incomplete read from ctl pipe, no rep_sz...");
|
|
442
|
+ pyfcgi_log(LOG_ERR, "Incomplete read from ctl pipe, no rep_sz...");
|
443
|
443
|
return -1;
|
444
|
444
|
}
|
445
|
445
|
return 0;
|
|
@@ -455,10 +455,10 @@ PyObject* import_entrypoint(char* py_entrypoint)
|
455
|
455
|
if(!entry_module)
|
456
|
456
|
{
|
457
|
457
|
//TODO syslog python error / traceback
|
458
|
|
- syslog( LOG_CRIT,
|
|
458
|
+ pyfcgi_log( LOG_CRIT,
|
459
|
459
|
"Unable to import python file '%s'",
|
460
|
460
|
py_entrypoint);
|
461
|
|
- syslog( LOG_INFO,
|
|
461
|
+ pyfcgi_log( LOG_INFO,
|
462
|
462
|
"%s", getcwd(NULL, 256));
|
463
|
463
|
log_expt(LOG_ERR);
|
464
|
464
|
sleep(1);
|
|
@@ -472,14 +472,14 @@ PyObject* import_entrypoint(char* py_entrypoint)
|
472
|
472
|
if(!entry_fun)
|
473
|
473
|
{
|
474
|
474
|
//TODO syslog python error / traceback
|
475
|
|
- syslog( LOG_CRIT,
|
|
475
|
+ pyfcgi_log( LOG_CRIT,
|
476
|
476
|
"Unable to import object '%s' from '%s'",
|
477
|
477
|
PYENTRY_FUNNAME, py_entrypoint);
|
478
|
478
|
Py_Exit(2);
|
479
|
479
|
}
|
480
|
480
|
if(!PyCallable_Check(entry_fun))
|
481
|
481
|
{
|
482
|
|
- syslog( LOG_CRIT,
|
|
482
|
+ pyfcgi_log( LOG_CRIT,
|
483
|
483
|
"When imported from '%s', '%s' was not a callable",
|
484
|
484
|
py_entrypoint, PYENTRY_FUNNAME);
|
485
|
485
|
Py_Exit(3);
|
|
@@ -493,7 +493,7 @@ static PyObject* _fetch_pyflush(const char *fdname)
|
493
|
493
|
pyfd = PySys_GetObject(fdname);
|
494
|
494
|
if(!pyfd)
|
495
|
495
|
{
|
496
|
|
- syslog(LOG_ALERT, "Unable to fetch sys.%s", fdname);
|
|
496
|
+ pyfcgi_log(LOG_ALERT, "Unable to fetch sys.%s", fdname);
|
497
|
497
|
log_expt(LOG_ALERT);
|
498
|
498
|
Py_Exit(EXIT_PYERR);
|
499
|
499
|
}
|
|
@@ -501,13 +501,13 @@ static PyObject* _fetch_pyflush(const char *fdname)
|
501
|
501
|
Py_DECREF(pyfd);
|
502
|
502
|
if(!pyflush)
|
503
|
503
|
{
|
504
|
|
- syslog(LOG_ALERT, "Unable to fetch sys.%s.flush", fdname);
|
|
504
|
+ pyfcgi_log(LOG_ALERT, "Unable to fetch sys.%s.flush", fdname);
|
505
|
505
|
log_expt(LOG_ALERT);
|
506
|
506
|
Py_Exit(EXIT_PYERR);
|
507
|
507
|
}
|
508
|
508
|
if(!PyCallable_Check(pyflush))
|
509
|
509
|
{
|
510
|
|
- syslog(LOG_ALERT, "sys.%s.flush is not callable !",
|
|
510
|
+ pyfcgi_log(LOG_ALERT, "sys.%s.flush is not callable !",
|
511
|
511
|
fdname);
|
512
|
512
|
Py_Exit(EXIT_PYERR);
|
513
|
513
|
}
|
|
@@ -581,7 +581,7 @@ void update_python_path()
|
581
|
581
|
}
|
582
|
582
|
else
|
583
|
583
|
{
|
584
|
|
- syslog(LOG_ALERT, "Unable to fetch python path, got NULL.");
|
|
584
|
+ pyfcgi_log(LOG_ALERT, "Unable to fetch python path, got NULL.");
|
585
|
585
|
}
|
586
|
586
|
err_fmt = NULL;
|
587
|
587
|
err = 0;
|
|
@@ -622,7 +622,7 @@ update_python_path_err_cwd:
|
622
|
622
|
update_python_path_err:
|
623
|
623
|
if(err_fmt)
|
624
|
624
|
{
|
625
|
|
- syslog( LOG_ALERT, err_fmt, strerror(err));
|
|
625
|
+ pyfcgi_log( LOG_ALERT, err_fmt, strerror(err));
|
626
|
626
|
}
|
627
|
627
|
exit(err);
|
628
|
628
|
}
|
|
@@ -657,7 +657,7 @@ void update_python_fd(int pipe_out[2], int pipe_err[2])
|
657
|
657
|
}
|
658
|
658
|
else
|
659
|
659
|
{
|
660
|
|
- syslog( LOG_ALERT,
|
|
660
|
+ pyfcgi_log( LOG_ALERT,
|
661
|
661
|
"Unable to import python os module, got NULL.");
|
662
|
662
|
}
|
663
|
663
|
err_fmt = NULL;
|
|
@@ -673,7 +673,7 @@ void update_python_fd(int pipe_out[2], int pipe_err[2])
|
673
|
673
|
}
|
674
|
674
|
else
|
675
|
675
|
{
|
676
|
|
- syslog( LOG_ALERT,
|
|
676
|
+ pyfcgi_log( LOG_ALERT,
|
677
|
677
|
"Unable to fetch os.fdopen() , got NULL.");
|
678
|
678
|
}
|
679
|
679
|
err_fmt = NULL;
|
|
@@ -683,7 +683,7 @@ void update_python_fd(int pipe_out[2], int pipe_err[2])
|
683
|
683
|
args = Py_BuildValue("is", pipe_out[1], "w");
|
684
|
684
|
if(!args)
|
685
|
685
|
{
|
686
|
|
- syslog( LOG_ERR, "Error building values with '%d', '%s' for stdout",
|
|
686
|
+ pyfcgi_log( LOG_ERR, "Error building values with '%d', '%s' for stdout",
|
687
|
687
|
pipe_out[1], "w");
|
688
|
688
|
log_expt(LOG_ALERT);
|
689
|
689
|
err_fmt = NULL;
|
|
@@ -692,7 +692,7 @@ void update_python_fd(int pipe_out[2], int pipe_err[2])
|
692
|
692
|
new_fd = PyObject_CallObject(pyfdopen, args);
|
693
|
693
|
if(!new_fd || PyErr_Occurred())
|
694
|
694
|
{
|
695
|
|
- syslog( LOG_ERR, "Error calling fdopen(%d, '%s')",
|
|
695
|
+ pyfcgi_log( LOG_ERR, "Error calling fdopen(%d, '%s')",
|
696
|
696
|
pipe_out[1], "w");
|
697
|
697
|
log_expt(LOG_ALERT);
|
698
|
698
|
err_fmt = NULL;
|
|
@@ -701,7 +701,7 @@ void update_python_fd(int pipe_out[2], int pipe_err[2])
|
701
|
701
|
Py_DECREF(args);
|
702
|
702
|
if(PySys_SetObject("stdout", new_fd))
|
703
|
703
|
{
|
704
|
|
- syslog(LOG_ERR, "Unable to set sys.stdout");
|
|
704
|
+ pyfcgi_log(LOG_ERR, "Unable to set sys.stdout");
|
705
|
705
|
log_expt(LOG_ALERT);
|
706
|
706
|
goto update_python_fd_err_newfd;
|
707
|
707
|
}
|
|
@@ -710,7 +710,7 @@ void update_python_fd(int pipe_out[2], int pipe_err[2])
|
710
|
710
|
args = Py_BuildValue("is", pipe_err[1], "w");
|
711
|
711
|
if(!args)
|
712
|
712
|
{
|
713
|
|
- syslog( LOG_ERR, "Error building values with '%d', '%s' for stderr",
|
|
713
|
+ pyfcgi_log( LOG_ERR, "Error building values with '%d', '%s' for stderr",
|
714
|
714
|
pipe_out[1], "w");
|
715
|
715
|
log_expt(LOG_ALERT);
|
716
|
716
|
err_fmt = NULL;
|
|
@@ -719,7 +719,7 @@ void update_python_fd(int pipe_out[2], int pipe_err[2])
|
719
|
719
|
new_fd = PyObject_CallObject(pyfdopen, args);
|
720
|
720
|
if(!new_fd || PyErr_Occurred())
|
721
|
721
|
{
|
722
|
|
- syslog( LOG_ERR, "Error calling fdopen(%d, '%s')",
|
|
722
|
+ pyfcgi_log( LOG_ERR, "Error calling fdopen(%d, '%s')",
|
723
|
723
|
pipe_out[1], "w");
|
724
|
724
|
log_expt(LOG_ALERT);
|
725
|
725
|
err_fmt = NULL;
|
|
@@ -728,7 +728,7 @@ void update_python_fd(int pipe_out[2], int pipe_err[2])
|
728
|
728
|
Py_DECREF(args);
|
729
|
729
|
if(PySys_SetObject("stderr", new_fd))
|
730
|
730
|
{
|
731
|
|
- syslog(LOG_ERR, "Unable to set sys.stderr");
|
|
731
|
+ pyfcgi_log(LOG_ERR, "Unable to set sys.stderr");
|
732
|
732
|
log_expt(LOG_ALERT);
|
733
|
733
|
goto update_python_fd_err_newfd;
|
734
|
734
|
}
|
|
@@ -751,7 +751,7 @@ update_python_fd_err_pipeout:
|
751
|
751
|
update_python_fd_err:
|
752
|
752
|
if(err_fmt)
|
753
|
753
|
{
|
754
|
|
- syslog(pri, err_fmt, strerror(err));
|
|
754
|
+ pyfcgi_log(pri, err_fmt, strerror(err));
|
755
|
755
|
}
|
756
|
756
|
exit(1);
|
757
|
757
|
}
|
|
@@ -767,7 +767,7 @@ void update_pyenv(PyObject *py_osmod, char **environ)
|
767
|
767
|
pyenv = PyObject_GetAttrString(py_osmod, "environ");
|
768
|
768
|
if(!pyenv)
|
769
|
769
|
{
|
770
|
|
- syslog(LOG_WARNING, "Unable to get os.environ");
|
|
770
|
+ pyfcgi_log(LOG_WARNING, "Unable to get os.environ");
|
771
|
771
|
log_expt(LOG_ALERT);
|
772
|
772
|
}
|
773
|
773
|
else
|
|
@@ -787,19 +787,19 @@ void update_pyenv(PyObject *py_osmod, char **environ)
|
787
|
787
|
}
|
788
|
788
|
if(!*value)
|
789
|
789
|
{
|
790
|
|
- syslog(LOG_WARNING, "Droping environment value without value : '%s'",
|
|
790
|
+ pyfcgi_log(LOG_WARNING, "Droping environment value without value : '%s'",
|
791
|
791
|
key);
|
792
|
792
|
cur++;
|
793
|
793
|
continue;
|
794
|
794
|
}
|
795
|
795
|
value++;
|
796
|
796
|
*(value-1) = '\0'; // dirty modification of **environ
|
797
|
|
-//syslog(LOG_DEBUG, "PySetEnv '%s'='%s'", key, value);
|
|
797
|
+//pyfcgi_log(LOG_DEBUG, "PySetEnv '%s'='%s'", key, value);
|
798
|
798
|
pykey = PyUnicode_DecodeLocale(key, "surrogateescape");
|
799
|
799
|
if(!pykey)
|
800
|
800
|
{
|
801
|
801
|
*(value-1) = '='; // **environ restore
|
802
|
|
- syslog(LOG_ALERT, "Unable to parse environ key string '%s'",
|
|
802
|
+ pyfcgi_log(LOG_ALERT, "Unable to parse environ key string '%s'",
|
803
|
803
|
key);
|
804
|
804
|
log_expt(LOG_ALERT);
|
805
|
805
|
Py_Exit(EXIT_PYERR);
|
|
@@ -808,14 +808,14 @@ void update_pyenv(PyObject *py_osmod, char **environ)
|
808
|
808
|
pyval = PyUnicode_DecodeFSDefault(value);
|
809
|
809
|
if(!pyval)
|
810
|
810
|
{
|
811
|
|
- syslog(LOG_ALERT, "Unable to parse environ val string '%s'",
|
|
811
|
+ pyfcgi_log(LOG_ALERT, "Unable to parse environ val string '%s'",
|
812
|
812
|
value);
|
813
|
813
|
log_expt(LOG_ALERT);
|
814
|
814
|
Py_Exit(EXIT_PYERR);
|
815
|
815
|
}
|
816
|
816
|
if(PyDict_SetItem(pyenv, pykey, pyval) == -1)
|
817
|
817
|
{
|
818
|
|
- syslog(LOG_ERR, "Unable to set environ '%s'='%s'",
|
|
818
|
+ pyfcgi_log(LOG_ERR, "Unable to set environ '%s'='%s'",
|
819
|
819
|
key, value);
|
820
|
820
|
log_expt(LOG_ERR);
|
821
|
821
|
}
|
|
@@ -831,7 +831,7 @@ void log_expt(int priority)
|
831
|
831
|
{
|
832
|
832
|
if(!PyErr_Occurred())
|
833
|
833
|
{
|
834
|
|
- syslog(priority, "No exception");
|
|
834
|
+ pyfcgi_log(priority, "No exception");
|
835
|
835
|
return;
|
836
|
836
|
}
|
837
|
837
|
|
|
@@ -847,7 +847,7 @@ void log_expt(int priority)
|
847
|
847
|
expt_str = PyObject_GetAttrString(expt, "__str__");
|
848
|
848
|
if(!expt_str)
|
849
|
849
|
{
|
850
|
|
- syslog(LOG_ERR, "Unable to fetch __str__ from exception");
|
|
850
|
+ pyfcgi_log(LOG_ERR, "Unable to fetch __str__ from exception");
|
851
|
851
|
}
|
852
|
852
|
expt_val = PyObject_CallObject(expt_str, NULL);
|
853
|
853
|
expt_bytes = PyUnicode_AsUTF8String(expt_val);
|
|
@@ -866,5 +866,5 @@ void log_expt(int priority)
|
866
|
866
|
msg = malloc(sizeof(char) * msg_sz);
|
867
|
867
|
snprintf(msg, msg_sz, msg_fmt, type, val);
|
868
|
868
|
|
869
|
|
- syslog(priority, msg);
|
|
869
|
+ pyfcgi_log(priority, msg);
|
870
|
870
|
}
|