~psycopg/psycopg/2.0.x

« back to all changes in this revision

Viewing changes to psycopg/connection_type.c

  • Committer: Federico Di Gregorio
  • Date: 2004-12-10 10:34:57 UTC
  • Revision ID: fog-1b2e9ebeaa5d76bd7e4a9dc5eb779afb4076f236
async fixes and better connection/cursor management.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
    /* TODO: added error checking on obj (cursor) here */
67
67
    
68
 
    /* add the cursor to this connection's list (and decref it, so that it has
69
 
       the right number of references to go away even if still in the list) */
70
 
    PyList_Append(self->cursors, obj);
71
 
    Py_DECREF(obj);
72
 
        
73
68
    Dprintf("psyco_conn_cursor: new cursor at %p: refcnt = %d",
74
69
            obj, obj->ob_refcnt);
75
70
    return obj;
244
239
    {"isolation_level", T_LONG,
245
240
     offsetof(connectionObject, isolation_level), RO},
246
241
    {"encoding", T_STRING, offsetof(connectionObject, encoding), RO},
247
 
    {"cursors", T_OBJECT, offsetof(connectionObject, cursors), RO},   
248
242
    {"notices", T_OBJECT, offsetof(connectionObject, notice_list), RO},
249
243
    {"notifies", T_OBJECT, offsetof(connectionObject, notifies), RO},
250
244
    {"dsn", T_STRING, offsetof(connectionObject, dsn), RO},
261
255
            self, ((PyObject *)self)->ob_refcnt);
262
256
    
263
257
    self->dsn = strdup(dsn);
264
 
    self->cursors = PyList_New(0);
265
258
    self->notice_list = PyList_New(0);
266
259
    self->closed = 0;
267
260
    self->isolation_level = 1;
273
266
    pthread_mutex_init(&(self->lock), NULL);
274
267
    
275
268
    if (conn_connect(self) != 0) {
276
 
        Py_XDECREF(self->cursors);
277
269
        pthread_mutex_destroy(&(self->lock));
278
270
        Dprintf("connection_init: FAILED");
279
271
        return -1;
291
283
 
292
284
    if (self->closed == 0) conn_close(self);
293
285
    
294
 
    Py_XDECREF(self->cursors);
295
286
    if (self->dsn) free(self->dsn);
296
287
    if (self->encoding) free(self->encoding);
297
288
    if (self->critical) free(self->critical);