apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bojan Smojver <bo...@rexursive.com>
Subject Re: Thread pool prototype
Date Thu, 04 May 2006 03:48:22 GMT
Quoting Joe Orton <jorton@redhat.com>:

> ... or OOM checking again.

A question in relation to this. I'm guessing there is not much use in  
checking for APR pool allocation errors because the program is going  
to blow up eventually, so these tests are mostly meaningless (at least  
that's how I understood the "don't check for NULLs" policy).

However, does the same apply to foreign APIs? I recently posted a  
patch for MySQL driver that does something like this:

------------------------------------
     (*statement)->stmt = mysql_stmt_init(sql->conn);

     if ((*statement)->stmt) {
         apr_pool_cleanup_register(pool, (*statement)->stmt,
                                   (void*)mysql_stmt_close,
                                   apr_pool_cleanup_null);
         return mysql_stmt_prepare((*statement)->stmt, myquery,  
strlen(myquery));
     }

     return  CR_OUT_OF_MEMORY;
------------------------------------

Basically, mysql_stmt_init() can return NULL here, which means that  
from *its* perspective, there is no more memory available. Do we trust  
foreign APIs then and just let things segfault (i.e. drop the "if  
((*statement)->stmt)"), or do we attempt to recover?

-- 
Bojan

Mime
View raw message