diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2007-11-09 02:28:47 +0000 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2007-11-09 02:28:47 +0000 |
| commit | 277f57ffb030b89544e878778dc385e3d0c59292 (patch) | |
| tree | dd51ee6402df27ab112d3db5ee446661103f4f2a /psycopg/connection_int.c | |
| parent | e1dd9ca8431e5a36c070fcfbdd94c8c0db0a3dc2 (diff) | |
| download | psycopg2-277f57ffb030b89544e878778dc385e3d0c59292.tar.gz | |
- Hard limit on the connection.notices list to avoid them
growing indefinitely.
Notices are treated as a queue: when the queue is full
drop the oldest notice.
Diffstat (limited to 'psycopg/connection_int.c')
| -rw-r--r-- | psycopg/connection_int.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 6995451..fb4018c 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -45,8 +45,13 @@ conn_notice_callback(void *args, const char *message) if (self->protocol < 3 && strncmp(message, "ERROR", 5) == 0) pq_set_critical(self, message); - else + else { PyList_Append(self->notice_list, PyString_FromString(message)); + + /* Remove the oldest item if the queue is getting too long. */ + if (PyList_GET_SIZE(self->notice_list) > CONN_NOTICES_LIMIT) + PySequence_DelItem(self->notice_list, 0); + } } /* conn_connect - execute a connection to the dataabase */ |
