diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2023-08-03 10:43:46 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2023-08-03 10:43:46 +0200 |
commit | c9a86dd1813b03aff74808035f7cae18133e2cbb (patch) | |
tree | bfc767522b051aca38185af7a1b110a42373e678 | |
parent | d9a54c3f6cbf068a1e1553eac9adcf9127b007f5 (diff) | |
download | pgfuse-c9a86dd1813b03aff74808035f7cae18133e2cbb.tar.gz pgfuse-c9a86dd1813b03aff74808035f7cae18133e2cbb.tar.bz2 |
added THREAD_ID helper in a util.h, done away with warnings on numerical thread systems
-rw-r--r-- | pgfuse.c | 3 | ||||
-rw-r--r-- | pool.c | 7 | ||||
-rw-r--r-- | util.h | 23 |
3 files changed, 28 insertions, 5 deletions
@@ -43,6 +43,7 @@ #endif #include "config.h" /* compiled in defaults */ +#include "util.h" /* common project utilities */ #include "pgsql.h" /* implements Postgresql accessers */ #include "pool.h" /* implements the connection pool */ @@ -107,8 +108,6 @@ static int psql_release( PgFuseData *data, PGconn *conn ) #define RELEASE( C ) \ if( psql_release( data, C ) < 0 ) return -EIO; -#define THREAD_ID pthread_self( ) - /* --- other helpers --- */ static int check_mountpoint( char **old_mountpoint ) @@ -16,6 +16,7 @@ */ #include "pool.h" +#include "util.h" /* common project utilities */ #include <string.h> /* for strlen, memcpy, strcmp */ #include <errno.h> /* for ENOENT and friends */ @@ -96,7 +97,7 @@ int psql_pool_destroy( PgConnPool *pool ) break; case USED: syslog( LOG_ERR, "Destroying pool connection to thread %p which is still in use", - pool->thread[i] ); + (void *)pool->thread[i] ); PQfinish( pool->conns[i] ); break; case ERROR: @@ -124,7 +125,7 @@ PGconn *psql_pool_acquire( PgConnPool *pool ) res = pthread_mutex_lock( &pool->lock ); if( res < 0 ) { syslog( LOG_ERR, "Locking mutex failed for thread %p: %d", - pthread_self( ), res ); + THREAD_ID, res ); return NULL; } @@ -146,7 +147,7 @@ PGconn *psql_pool_acquire( PgConnPool *pool ) res = pthread_cond_wait( &pool->cond, &pool->lock ); if( res < 0 ) { syslog( LOG_ERR, "Error waiting for free condition in thread %p: %d", - pthread_self( ), res ); + THREAD_ID, res ); (void)pthread_mutex_unlock( &pool->lock ); return NULL; } @@ -0,0 +1,23 @@ +/* + Copyright (C) 2012 - 2015 Andreas Baumann <mail@andreasbaumann.cc> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef UTIL_H +#define UTIL_H + +#define THREAD_ID ( (void *)pthread_self( ) ) + +#endif |