~songofacandy/pyopenssl/allow_thread_while_keygen

« back to all changes in this revision

Viewing changes to OpenSSL/ssl/connection.c

  • Committer: Jean-Paul Calderone
  • Date: 2011-01-22 15:04:48 UTC
  • mfrom: (139.1.4 send-memoryview)
  • Revision ID: exarkun@divmod.com-20110122150448-v3zadoqmhi4lhkeb
Merge send-memoryview

Show diffs side-by-side

added added

removed removed

Lines of Context:
331
331
@return: The number of bytes written\n\
332
332
";
333
333
static PyObject *
334
 
ssl_Connection_send(ssl_ConnectionObj *self, PyObject *args)
335
 
{
 
334
ssl_Connection_send(ssl_ConnectionObj *self, PyObject *args) {
 
335
    int len, ret, err, flags;
336
336
    char *buf;
337
 
    int len, ret, err, flags;
 
337
 
 
338
#if PY_VERSION_HEX >= 0x02060000
 
339
    Py_buffer pbuf;
 
340
 
 
341
    if (!PyArg_ParseTuple(args, "s*|i:send", &pbuf, &flags))
 
342
        return NULL;
 
343
 
 
344
    buf = pbuf.buf;
 
345
    len = pbuf.len;
 
346
#else
338
347
 
339
348
    if (!PyArg_ParseTuple(args, "s#|i:send", &buf, &len, &flags))
340
349
        return NULL;
 
350
#endif
341
351
 
342
352
    MY_BEGIN_ALLOW_THREADS(self->tstate)
343
353
    ret = SSL_write(self->ssl, buf, len);
344
354
    MY_END_ALLOW_THREADS(self->tstate)
345
355
 
 
356
#if PY_VERSION_HEX >= 0x02060000
 
357
    PyBuffer_Release(&pbuf);
 
358
#endif
 
359
 
346
360
    if (PyErr_Occurred())
347
361
    {
348
362
        flush_error_queue();
378
392
    int len, ret, err, flags;
379
393
    PyObject *pyret = Py_None;
380
394
 
 
395
#if PY_VERSION_HEX >= 0x02060000
 
396
    Py_buffer pbuf;
 
397
 
 
398
    if (!PyArg_ParseTuple(args, "s*|i:sendall", &pbuf, &flags))
 
399
        return NULL;
 
400
 
 
401
    buf = pbuf.buf;
 
402
    len = pbuf.len;
 
403
#else
381
404
    if (!PyArg_ParseTuple(args, "s#|i:sendall", &buf, &len, &flags))
382
405
        return NULL;
 
406
#endif
383
407
 
384
408
    do {
385
409
        MY_BEGIN_ALLOW_THREADS(self->tstate)
403
427
            handle_ssl_errors(self->ssl, err, ret);
404
428
            pyret = NULL;
405
429
            break;
406
 
        }    
 
430
        }
407
431
    } while (len > 0);
408
432
 
 
433
#if PY_VERSION_HEX >= 0x02060000
 
434
    PyBuffer_Release(&pbuf);
 
435
#endif
 
436
 
409
437
    Py_XINCREF(pyret);
410
438
    return pyret;
411
439
}