diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-31 12:54:10 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-31 12:54:10 +0000 |
commit | 41fb70130f992f9d9ea848fa99778def76d95d05 (patch) | |
tree | 1f40ace013cf31fefe7f298f6f6d0d6529b11f64 | |
parent | 260e2be5d69d9fe7ec3fd533430b9bd6effd55c0 (diff) | |
download | rsyslog-41fb70130f992f9d9ea848fa99778def76d95d05.tar.gz rsyslog-41fb70130f992f9d9ea848fa99778def76d95d05.tar.xz rsyslog-41fb70130f992f9d9ea848fa99778def76d95d05.zip |
bugfix: having fun with 32/64 bit portability - after 15 years, I finally
was trapped again ;) -- now fixed, sizes > 2GB supported on 32bit
platforms
-rw-r--r-- | action.c | 8 | ||||
-rw-r--r-- | cfsysline.c | 18 | ||||
-rw-r--r-- | queue.c | 14 | ||||
-rw-r--r-- | queue.h | 8 | ||||
-rw-r--r-- | rsyslog.h | 5 | ||||
-rw-r--r-- | stream.c | 2 | ||||
-rw-r--r-- | stream.h | 8 | ||||
-rw-r--r-- | syslogd.c | 6 |
8 files changed, 37 insertions, 32 deletions
@@ -58,7 +58,7 @@ static int iActionQDiscardMark = 9800; /* begin to discard messages */ static int iActionQDiscardSeverity = 4; /* discard warning and above */ static int iActionQueueNumWorkers = 1; /* number of worker threads for the mm queue above */ static uchar *pszActionQFName = NULL; /* prefix for the main message queue file */ -static size_t iActionQueMaxFileSize = 1024*1024; +static int64 iActionQueMaxFileSize = 1024*1024; static int iActionQPersistUpdCnt = 0; /* persist queue info every n updates */ static int iActionQtoQShutdown = 0; /* queue shutdown */ static int iActionQtoActShutdown = 1000; /* action shutdown (in phase 2) */ @@ -67,7 +67,7 @@ static int iActionQtoWrkShutdown = 60000; /* timeout for worker thread shutdow static int iActionQWrkMinMsgs = 100; /* minimum messages per worker needed to start a new one */ static int bActionQSaveOnShutdown = 1; /* save queue on shutdown (when DA enabled)? */ static int iActionQueueDeqSlowdown = 0; /* dequeue slowdown (simple rate limiting) */ -static size_t iActionQueMaxDiskSpace = 0; /* max disk space allocated 0 ==> unlimited */ +static int64 iActionQueMaxDiskSpace = 0; /* max disk space allocated 0 ==> unlimited */ /* the counter below counts actions created. It is used to obtain unique IDs for the action. They * should not be relied on for any long-term activity (e.g. disk queue names!), but they are nice @@ -223,9 +223,9 @@ actionConstructFinalize(action_t *pThis) # undef setQPROP # undef setQPROPstr - /*dbgoprint((obj_t*) pThis->pQueue, "save on shutdown %d, max disk space allowed %ld\n", + dbgoprint((obj_t*) pThis->pQueue, "save on shutdown %d, max disk space allowed %lld\n", bActionQSaveOnShutdown, iActionQueMaxDiskSpace); - */ + CHKiRet(queueStart(pThis->pQueue)); dbgprintf("Action %p: queue %p created\n", pThis, pThis->pQueue); diff --git a/cfsysline.c b/cfsysline.c index d307569b..0cc6c134 100644 --- a/cfsysline.c +++ b/cfsysline.c @@ -101,11 +101,11 @@ finalize_it: * for INTERNAL USE by other parse functions! * rgerhards, 2008-01-08 */ -static rsRetVal parseIntVal(uchar **pp, size_t *pVal) +static rsRetVal parseIntVal(uchar **pp, int64 *pVal) { DEFiRet; uchar *p; - size_t i; + int64 i; int bWasNegative; assert(pp != NULL); @@ -153,7 +153,7 @@ static rsRetVal doGetInt(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p { uchar *p; DEFiRet; - size_t i; + int64 i; assert(pp != NULL); assert(*pp != NULL); @@ -179,13 +179,13 @@ finalize_it: /* Parse a size from the configuration line. This is basically an integer * syntax, but modifiers may be added after the integer (e.g. 1k to mean * 1024). The size must immediately follow the number. Note that the - * param value must be size_t! + * param value must be int64! * rgerhards, 2008-01-09 */ static rsRetVal doGetSize(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal) { DEFiRet; - size_t i; + int64 i; assert(pp != NULL); assert(*pp != NULL); @@ -201,9 +201,9 @@ static rsRetVal doGetSize(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void * case 'k': i *= 1024; ++(*pp); break; case 'm': i *= 1024 * 1024; ++(*pp); break; case 'g': i *= 1024 * 1024 * 1024; ++(*pp); break; - case 't': i *= (size_t) 1024 * 1024 * 1024 * 1024; ++(*pp); break; /* tera */ - case 'p': i *= (size_t) 1024 * 1024 * 1024 * 1024 * 1024; ++(*pp); break; /* peta */ - case 'e': i *= (size_t) 1024 * 1024 * 1024 * 1024 * 1024 * 1024; ++(*pp); break; /* exa */ + case 't': i *= (int64) 1024 * 1024 * 1024 * 1024; ++(*pp); break; /* tera */ + case 'p': i *= (int64) 1024 * 1024 * 1024 * 1024 * 1024; ++(*pp); break; /* peta */ + case 'e': i *= (int64) 1024 * 1024 * 1024 * 1024 * 1024 * 1024; ++(*pp); break; /* exa */ /* and now the "new" 1000-based definitions */ case 'K': i *= 1000; ++(*pp); break; case 'M': i *= 10000; ++(*pp); break; @@ -216,7 +216,7 @@ static rsRetVal doGetSize(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void * /* done */ if(pSetHdlr == NULL) { /* we should set value directly to var */ - *((size_t*)pVal) = i; + *((int64*)pVal) = i; } else { /* we set value via a set function */ CHKiRet(pSetHdlr(pVal, i)); @@ -818,8 +818,8 @@ static rsRetVal qDestructDisk(queue_t *pThis) static rsRetVal qAddDisk(queue_t *pThis, void* pUsr) { DEFiRet; - size_t offsIn; - size_t offsOut; + int64 offsIn; + int64 offsOut; ASSERT(pThis != NULL); @@ -839,7 +839,7 @@ static rsRetVal qAddDisk(queue_t *pThis, void* pUsr) pThis->tVars.disk.sizeOnDisk += offsIn; - dbgoprint((obj_t*) pThis, "write wrote %ld octets to disk, queue disk size now %ld octets\n", offsIn, pThis->tVars.disk.sizeOnDisk); + dbgoprint((obj_t*) pThis, "write wrote %lld octets to disk, queue disk size now %lld octets\n", offsIn, pThis->tVars.disk.sizeOnDisk); finalize_it: RETiRet; @@ -849,8 +849,8 @@ static rsRetVal qDelDisk(queue_t *pThis, void **ppUsr) { DEFiRet; - size_t offsIn; - size_t offsOut; + int64 offsIn; + int64 offsOut; CHKiRet(strmGetCurrOffset(pThis->tVars.disk.pRead, &offsIn)); CHKiRet(objDeserialize(ppUsr, OBJmsg, pThis->tVars.disk.pRead, NULL, NULL)); @@ -866,7 +866,7 @@ static rsRetVal qDelDisk(queue_t *pThis, void **ppUsr) } else { pThis->tVars.disk.sizeOnDisk -= pThis->tVars.disk.bytesRead; pThis->tVars.disk.bytesRead = offsOut; - dbgoprint((obj_t*) pThis, "a file has been deleted, now %ld octets disk space used\n", pThis->tVars.disk.sizeOnDisk); + dbgoprint((obj_t*) pThis, "a file has been deleted, now %lld octets disk space used\n", pThis->tVars.disk.sizeOnDisk); /* awake possibly waiting enq process */ pthread_cond_signal(&pThis->notFull); /* we hold the mutex while we are in here! */ } @@ -1622,7 +1622,7 @@ rsRetVal queueStart(queue_t *pThis) /* this is the ConstructionFinalizer */ /* call type-specific constructor */ CHKiRet(pThis->qConstruct(pThis)); /* this also sets bIsDA */ - dbgoprint((obj_t*) pThis, "type %d, enq-only %d, disk assisted %d, maxFileSz %ld, qsize %d, child %d starting\n", + dbgoprint((obj_t*) pThis, "type %d, enq-only %d, disk assisted %d, maxFileSz %lld, qsize %d, child %d starting\n", pThis->qType, pThis->bEnqOnly, pThis->bIsDA, pThis->iMaxFileSize, queueGetOverallQueueSize(pThis), pThis->pqParent == NULL ? 0 : 1); @@ -113,8 +113,8 @@ typedef struct queue_s { uchar *pszFilePrefix; size_t lenFilePrefix; int iNumberFiles; /* how many files make up the queue? */ - size_t iMaxFileSize; /* max size for a single queue file */ - size_t sizeOnDiskMax; /* maximum size on disk allowed */ + int64 iMaxFileSize; /* max size for a single queue file */ + int64 sizeOnDiskMax; /* maximum size on disk allowed */ int bIsDA; /* is this queue disk assisted? */ int bRunsDA; /* is this queue actually *running* disk assisted? */ struct queue_s *pqDA; /* queue for disk-assisted modes */ @@ -137,8 +137,8 @@ typedef struct queue_s { qLinkedList_t *pLast; } linklist; struct { - size_t sizeOnDisk; /* current amount of disk space used */ - size_t bytesRead; /* number of bytes read from current (undeleted!) file */ + int64 sizeOnDisk; /* current amount of disk space used */ + int64 bytesRead; /* number of bytes read from current (undeleted!) file */ strm_t *pWrite; /* current file to be written */ strm_t *pRead; /* current file to be read */ } disk; @@ -43,6 +43,11 @@ # define _FILE_OFFSET_BITS 64 #endif + +/* some universal 64 bit define... */ +typedef long long int64; +typedef long long unsigned uint64; + /* The error codes below are orginally "borrowed" from * liblogging. As such, we reserve values up to -2999 * just in case we need to borrow something more ;) @@ -760,7 +760,7 @@ finalize_it: * file circulation. A caller must deal with that. -- rgerhards, 2008-01-30 */ rsRetVal -strmGetCurrOffset(strm_t *pThis, size_t *pOffs) +strmGetCurrOffset(strm_t *pThis, int64 *pOffs) { DEFiRet; @@ -70,11 +70,11 @@ typedef struct strm_s { strmMode_t tOperationsMode; mode_t tOpenMode; int iAddtlOpenFlags; /* can be used to specifiy additional (compatible!) open flags */ - size_t iMaxFileSize;/* maximum size a file may grow to */ + int64 iMaxFileSize;/* maximum size a file may grow to */ int iMaxFiles; /* maximum number of files if a circular mode is in use */ int iFileNumDigits;/* min number of digits to use in file number (only in circular mode) */ int bDeleteOnClose; /* set to 1 to auto-delete on close -- be careful with that setting! */ - size_t iCurrOffs;/* current offset */ + int64 iCurrOffs;/* current offset */ /* dynamic properties, valid only during file open, not to be persistet */ size_t sIOBufSize;/* size of IO buffer */ uchar *pszDir; /* Directory */ @@ -92,7 +92,7 @@ typedef struct strm_s { rsRetVal strmConstruct(strm_t **ppThis); rsRetVal strmConstructFinalize(strm_t __attribute__((unused)) *pThis); rsRetVal strmDestruct(strm_t **ppThis); -rsRetVal strmSetMaxFileSize(strm_t *pThis, size_t iMaxFileSize); +rsRetVal strmSetMaxFileSize(strm_t *pThis, int64 iMaxFileSize); rsRetVal strmSetFileName(strm_t *pThis, uchar *pszName, size_t iLenName); rsRetVal strmReadChar(strm_t *pThis, uchar *pC); rsRetVal strmUnreadChar(strm_t *pThis, uchar c); @@ -107,7 +107,7 @@ rsRetVal strmRecordBegin(strm_t *pThis); rsRetVal strmRecordEnd(strm_t *pThis); rsRetVal strmSerialize(strm_t *pThis, strm_t *pStrm); rsRetVal strmSetiAddtlOpenFlags(strm_t *pThis, int iNewVal); -rsRetVal strmGetCurrOffset(strm_t *pThis, size_t *pOffs); +rsRetVal strmGetCurrOffset(strm_t *pThis, int64 *pOffs); PROTOTYPEObjClassInit(strm); PROTOTYPEpropSetMeth(strm, bDeleteOnClose, int); PROTOTYPEpropSetMeth(strm, iMaxFileSize, int); @@ -407,7 +407,7 @@ static int iMainMsgQDiscardSeverity = 4; /* discard warning and above */ static int iMainMsgQueueNumWorkers = 1; /* number of worker threads for the mm queue above */ static queueType_t MainMsgQueType = QUEUETYPE_FIXED_ARRAY; /* type of the main message queue above */ static uchar *pszMainMsgQFName = NULL; /* prefix for the main message queue file */ -static size_t iMainMsgQueMaxFileSize = 1024*1024; +static int64 iMainMsgQueMaxFileSize = 1024*1024; static int iMainMsgQPersistUpdCnt = 0; /* persist queue info every n updates */ static int iMainMsgQtoQShutdown = 0; /* queue shutdown */ static int iMainMsgQtoActShutdown = 1000; /* action shutdown (in phase 2) */ @@ -416,7 +416,7 @@ static int iMainMsgQtoWrkShutdown = 60000; /* timeout for worker thread shutdo static int iMainMsgQWrkMinMsgs = 100; /* minimum messages per worker needed to start a new one */ static int iMainMsgQDeqSlowdown = 0; /* dequeue slowdown (simple rate limiting) */ static int bMainMsgQSaveOnShutdown = 1; /* save queue on shutdown (when DA enabled)? */ -static size_t iMainMsgQueMaxDiskSpace = 0; /* max disk space allocated 0 ==> unlimited */ +static int64 iMainMsgQueMaxDiskSpace = 0; /* max disk space allocated 0 ==> unlimited */ /* This structure represents the files that will have log @@ -2942,7 +2942,7 @@ static void dbgPrintInitInfo(void) iMainMsgQtoQShutdown, iMainMsgQtoActShutdown, iMainMsgQtoEnq); dbgprintf("Main queue watermarks: high: %d, low: %d, discard: %d, discard-severity: %d\n", iMainMsgQHighWtrMark, iMainMsgQLowWtrMark, iMainMsgQDiscardMark, iMainMsgQDiscardSeverity); - dbgprintf("Main queue save on shutdown %d, max disk space allowed %ld\n", + dbgprintf("Main queue save on shutdown %d, max disk space allowed %lld\n", bMainMsgQSaveOnShutdown, iMainMsgQueMaxDiskSpace); /* TODO: add iActionRetryCount = 0; |