Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Simplified error handling

  • Loading branch information...
commit de59bb7f8c2113786d5d51db26e8a897ed112f13 1 parent 98ec708
Saúl Ibarra Corretgé authored December 27, 2012

Showing 2 changed files with 4 additions and 6 deletions. Show diff stats Hide diff stats

  1. 5  src/loop.c
  2. 5  src/util.c
5  src/loop.c
@@ -238,7 +238,6 @@ Loop_func_queue_work(Loop *self, PyObject *args)
238 238
         PyErr_NoMemory();
239 239
         goto error;
240 240
     }
241  
-    Py_INCREF(pyreq);
242 241
     ((Request *)pyreq)->req = (uv_req_t *)req;
243 242
     pyreq->work_cb = work_cb;
244 243
     pyreq->done_cb = done_cb;
@@ -250,19 +249,19 @@ Loop_func_queue_work(Loop *self, PyObject *args)
250 249
     r = uv_queue_work(self->uv_loop, req, threadpool_work_cb, threadpool_done_cb);
251 250
     if (r != 0) {
252 251
         RAISE_UV_EXCEPTION(self->uv_loop, PyExc_Exception);
253  
-        Py_DECREF(pyreq);
254 252
         goto error;
255 253
     }
256 254
 
257 255
     Py_INCREF(self);
258 256
 
  257
+    Py_INCREF(pyreq);
259 258
     return (PyObject *)pyreq;
260 259
 
261 260
 error:
262  
-    PyMem_Free(req);
263 261
     Py_XDECREF(pyreq);
264 262
     Py_DECREF(work_cb);
265 263
     Py_XDECREF(done_cb);
  264
+    PyMem_Free(req);
266 265
     return NULL;
267 266
 }
268 267
 
5  src/util.c
@@ -433,7 +433,6 @@ Util_func_getaddrinfo(PyObject *obj, PyObject *args, PyObject *kwargs)
433 433
         PyErr_NoMemory();
434 434
         goto error;
435 435
     }
436  
-    Py_INCREF(pyreq);
437 436
     ((Request *)pyreq)->req = (uv_req_t *)req;
438 437
     pyreq->callback = callback;
439 438
 
@@ -450,15 +449,15 @@ Util_func_getaddrinfo(PyObject *obj, PyObject *args, PyObject *kwargs)
450 449
     r = uv_getaddrinfo(loop->uv_loop, req, &getaddrinfo_cb, host_str, port_str, &hints);
451 450
     if (r != 0) {
452 451
         RAISE_UV_EXCEPTION(loop->uv_loop, PyExc_UVError);
453  
-        Py_DECREF(pyreq);
454 452
         goto error;
455 453
     }
456 454
 
  455
+    Py_INCREF(pyreq);
457 456
     return (PyObject *)pyreq;
458 457
 
459 458
 error:
460  
-    PyMem_Free(req);
461 459
     Py_XDECREF(pyreq);
  460
+    PyMem_Free(req);
462 461
     return NULL;
463 462
 }
464 463
 

0 notes on commit de59bb7

Please sign in to comment.
Something went wrong with that request. Please try again.