|
@@ -295,7 +295,7 @@ PyObject* pyfcgi_ioin_read(PyObject *self, PyObject **argv, Py_ssize_t argc)
|
295
|
295
|
{
|
296
|
296
|
size_t left, sz, max;
|
297
|
297
|
long l;
|
298
|
|
- int read_n, toread;
|
|
298
|
+ int read_n, toread, ret;
|
299
|
299
|
PyObject *res, *read_str;
|
300
|
300
|
char *buff;
|
301
|
301
|
|
|
@@ -333,26 +333,33 @@ PyObject* pyfcgi_ioin_read(PyObject *self, PyObject **argv, Py_ssize_t argc)
|
333
|
333
|
{
|
334
|
334
|
Py_RETURN_NONE;
|
335
|
335
|
}
|
|
336
|
+ Py_INCREF(res);
|
336
|
337
|
while((max && left) || !max)
|
337
|
338
|
{
|
338
|
339
|
toread = (max&&((size_t)read_n > left))?(int)left:read_n;
|
339
|
|
- if(FCGX_GetStr(buff, toread, *((IoIn*)self)->in_stream) < toread)
|
340
|
|
- {
|
341
|
|
- ((IoIn*)self)->eof = 1;
|
342
|
|
- break;
|
343
|
|
- }
|
|
340
|
+ ret = FCGX_GetStr(buff, toread, *((IoIn*)self)->in_stream);
|
|
341
|
+
|
344
|
342
|
sz = strlen(buff);
|
345
|
|
- left -= sz;
|
346
|
|
- if(!(read_str = IoIn__FromBuff(self)))
|
|
343
|
+ if(sz)
|
347
|
344
|
{
|
348
|
|
- Py_RETURN_NONE;
|
|
345
|
+ left -= sz;
|
|
346
|
+ if(!(read_str = IoIn__FromBuff(self)))
|
|
347
|
+ {
|
|
348
|
+ Py_RETURN_NONE;
|
|
349
|
+ }
|
|
350
|
+ Py_INCREF(read_str);
|
|
351
|
+ if(!(res = IoIn__Concat(self, res, read_str)))
|
|
352
|
+ {
|
|
353
|
+ Py_RETURN_NONE;
|
|
354
|
+ }
|
|
355
|
+ Py_INCREF(res);
|
349
|
356
|
}
|
350
|
|
- Py_INCREF(read_str);
|
351
|
|
- if(!(res = IoIn__Concat(self, res, read_str)))
|
|
357
|
+
|
|
358
|
+ if( ret < toread)
|
352
|
359
|
{
|
353
|
|
- Py_RETURN_NONE;
|
|
360
|
+ ((IoIn*)self)->eof = 1;
|
|
361
|
+ break;
|
354
|
362
|
}
|
355
|
|
- Py_INCREF(res);
|
356
|
363
|
}
|
357
|
364
|
Py_DECREF(res);
|
358
|
365
|
return res;
|