Get rid of store's printfs and make it log properly.
This commit is contained in:
+20
-21
@@ -403,7 +403,7 @@ DStoreCreateDB(DStoreHandle *handle)
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
printf("DStoreCreateDB error: %s\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_ERROR, "DStoreCreateDB error: %s", sqlite3_errmsg(handle->db));
|
||||
|
||||
DStoreAbortTransaction(handle);
|
||||
DStoreClose(handle);
|
||||
@@ -426,18 +426,18 @@ UpgradeDB(DStoreHandle *handle)
|
||||
#define CURRENT_VERSION 2
|
||||
|
||||
if (DStoreBeginTransaction(handle)) {
|
||||
printf("UpgradeDB error: %s\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_ERROR, "UpgradeDB error: %s", sqlite3_errmsg(handle->db));
|
||||
return -1;
|
||||
}
|
||||
|
||||
stmt = SqlPrepare(handle, "PRAGMA user_version;", &handle->stmts.getVersion);
|
||||
if (!stmt) {
|
||||
printf("UpgradeDB error: %s\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_ERROR, "UpgradeDB error: %s", sqlite3_errmsg(handle->db));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (1 != DStoreStmtStep(handle, stmt)) {
|
||||
printf("UpgradeDB error: %s\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_ERROR, "UpgradeDB error: %s", sqlite3_errmsg(handle->db));
|
||||
DStoreStmtEnd(handle, stmt);
|
||||
goto fail;
|
||||
}
|
||||
@@ -457,7 +457,7 @@ UpgradeDB(DStoreHandle *handle)
|
||||
,
|
||||
NULL, NULL, NULL);
|
||||
if (SQLITE_OK != dcode) {
|
||||
printf("error: %s\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_ERROR, "Couldn't add mime_cache table: %s\n", sqlite3_errmsg(handle->db));
|
||||
goto fail;
|
||||
}
|
||||
case 1:
|
||||
@@ -465,13 +465,13 @@ UpgradeDB(DStoreHandle *handle)
|
||||
"ALTER TABLE docs ADD COLUMN stamp TEXT DEFAULT NULL;",
|
||||
NULL, NULL, NULL);
|
||||
if (SQLITE_OK != dcode) {
|
||||
printf("error: %s\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_ERROR, "Couldn't update docs table: %s\n", sqlite3_errmsg(handle->db));
|
||||
goto fail;
|
||||
}
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
printf("Illegal database version %d", CURRENT_VERSION);
|
||||
Log(LOG_ERROR, "Illegal database version %d found", CURRENT_VERSION);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -484,13 +484,13 @@ UpgradeDB(DStoreHandle *handle)
|
||||
|
||||
DStoreReset(handle);
|
||||
|
||||
printf("Upgraded store to version %d.\n", CURRENT_VERSION);
|
||||
Log(LOG_INFO, "Upgraded store to version %d", CURRENT_VERSION);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
DStoreAbortTransaction(handle);
|
||||
if (-1 != version) {
|
||||
printf("Unable to upgrade store from version %d to version %d.\n",
|
||||
Log(LOG_ERROR, "Unable to upgrade store from version %d to version %d.",
|
||||
version, CURRENT_VERSION);
|
||||
}
|
||||
return -1;
|
||||
@@ -519,8 +519,7 @@ DStoreOpen(char *basepath, BongoMemStack *memstack, int locktimeoutms)
|
||||
(memset(handle, 0, sizeof(struct _DStoreHandle)), 0) ||
|
||||
(SQLITE_OK != sqlite3_open(path, &handle->db)))
|
||||
{
|
||||
XplConsolePrintf("NMAP: Failed to open dstore \"%s\".\r\n",
|
||||
path);
|
||||
Log(LOG_ERROR, "Failed to open dstore \"%s\"", path);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -529,7 +528,7 @@ DStoreOpen(char *basepath, BongoMemStack *memstack, int locktimeoutms)
|
||||
handle->lockTimeoutMs = locktimeoutms;
|
||||
|
||||
if (create && DStoreCreateDB(handle)) {
|
||||
printf("Couldn't open db");
|
||||
Log(LOG_ERROR, "Couldn't open dstore db");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -569,7 +568,7 @@ DStoreClose(DStoreHandle *handle)
|
||||
{
|
||||
DStoreReset(handle);
|
||||
if (SQLITE_BUSY == sqlite3_close(handle->db)) {
|
||||
XplConsolePrintf ("Store: couldn't close dstore database!\r\n");
|
||||
Log (LOG_ERROR, "Couldn't close dstore database");
|
||||
}
|
||||
|
||||
MemFree(handle);
|
||||
@@ -615,12 +614,12 @@ SqlPrepare(DStoreHandle *handle, const char *statement, DStoreStmt *stmt)
|
||||
XplDelay(STMT_SLEEP_MS);
|
||||
continue;
|
||||
default:
|
||||
XplConsolePrintf("SQL Prepare statement \"%s\" failed; %s\r\n",
|
||||
Log(LOG_INFO, "SQL Prepare statement \"%s\" failed; %s",
|
||||
statement, sqlite3_errmsg(handle->db));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
XplConsolePrintf("Sql Prepare failed because db is busy.\r\n");
|
||||
Log(LOG_ERROR, "Sql Prepare failed because db is busy.\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -681,11 +680,11 @@ DStoreStmtStep(DStoreHandle *handle,
|
||||
XplDelay(STMT_SLEEP_MS);
|
||||
continue;
|
||||
default:
|
||||
XplConsolePrintf("Sql: %s\r\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_INFO, "Sql: %s", sqlite3_errmsg(handle->db));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
XplConsolePrintf("Sql Busy.\r\n");
|
||||
Log(LOG_ERROR, "Sql Busy.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -700,7 +699,7 @@ DStoreStmtExecute(DStoreHandle *handle, DStoreStmt *_stmt)
|
||||
if (SQLITE_DONE == result) {
|
||||
return 0;
|
||||
} else {
|
||||
XplConsolePrintf("Sql: %s\r\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_ERROR, "Sql: %s", sqlite3_errmsg(handle->db));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -709,7 +708,7 @@ DStoreStmtExecute(DStoreHandle *handle, DStoreStmt *_stmt)
|
||||
void
|
||||
DStoreStmtError(DStoreHandle *handle, DStoreStmt *stmt)
|
||||
{
|
||||
XplConsolePrintf("Sql: %s\r\n", sqlite3_errmsg(handle->db));
|
||||
Log(LOG_ERROR, "Sql: %s\r\n", sqlite3_errmsg(handle->db));
|
||||
}
|
||||
|
||||
|
||||
@@ -894,7 +893,7 @@ retry:
|
||||
return result;
|
||||
}
|
||||
if (DOCINFO_SIZE != sqlite3_column_bytes(stmt->stmt, 1)) {
|
||||
XplConsolePrintf("Store DB error: Incompatible docs table.\r\n");
|
||||
Log(LOG_ERROR, "Store DB error: Incompatible docs table.");
|
||||
return -1;
|
||||
}
|
||||
data = sqlite3_column_blob(stmt->stmt, 1);
|
||||
@@ -1887,7 +1886,7 @@ test_headers(sqlite3_context *ctx, int argc, sqlite3_value **argv)
|
||||
p = subject;
|
||||
break;
|
||||
default:
|
||||
printf("test_headers(): Bad header type.\n");
|
||||
Log(LOG_ERROR, "test_headers(): Bad header type.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -355,13 +355,13 @@ ReadNMAPLockAcquire(NLockStruct **lockHandle, unsigned long *hashHandle, unsigne
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
XplConsolePrintf("NMAP: ReadNMAPLockAcquire() called with an existing lock from %s:%lu\r\n", file, line);
|
||||
Log(LOG_DEBUG, "ReadNMAPLockAcquire() called with an existing lock from %s:%lu", file, line);
|
||||
#endif
|
||||
|
||||
return(NLOCK_HANDLE_HAS_LOCK);
|
||||
}
|
||||
#if defined(DEBUG)
|
||||
XplConsolePrintf("NMAP: ReadNMAPLockAcquire() called with a NULL lock handle from %s:%lu\r\n", file, line);
|
||||
Log(LOG_DEBUG, "ReadNMAPLockAcquire() called with a NULL lock handle from %s:%lu", file, line);
|
||||
#endif
|
||||
|
||||
return(NLOCK_HANDLE_NOT_PROVIDED);
|
||||
@@ -390,7 +390,7 @@ ReadNMAPLockRelease(NLockStruct *lockHandle, unsigned char *file, unsigned long
|
||||
if ((lockHandle->wLock == 0) && (lockHandle->eLock == 0)) {
|
||||
;
|
||||
} else {
|
||||
XplConsolePrintf("NMAP: ReadNMAPLockRelease() called with values RLock = %lu WLock = %lu and ELock = %lu from %s:%lu\r\n", lockHandle->rLock, lockHandle->wLock, lockHandle->eLock, file, line);
|
||||
Log(LOG_DEBUG, "ReadNMAPLockRelease() called with values RLock = %lu WLock = %lu and ELock = %lu from %s:%lu", lockHandle->rLock, lockHandle->wLock, lockHandle->eLock, file, line);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -447,14 +447,14 @@ ReadNMAPLockRelease(NLockStruct *lockHandle, unsigned char *file, unsigned long
|
||||
|
||||
XplSignalLocalSemaphore(NLockHeadArray[lockHandle->slot].lock);
|
||||
#if defined(DEBUG)
|
||||
XplConsolePrintf("NMAP: ReadNMAPLockRelease() called with no readers from %s:%lu\r\n", file, line);
|
||||
Log(LOG_DEBUG, "ReadNMAPLockRelease() called with no readers from %s:%lu", file, line);
|
||||
#endif
|
||||
|
||||
return(NLOCK_INVALID);
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
XplConsolePrintf("NMAP: ReadNMAPLockRelease() called with an NULL lock handle from %s:%lu\r\n", file, line);
|
||||
Log(LOG_DEBUG, "ReadNMAPLockRelease() called with an NULL lock handle from %s:%lu", file, line);
|
||||
#endif
|
||||
|
||||
return(NLOCK_INVALID);
|
||||
@@ -513,7 +513,7 @@ WriteNMAPLockAcquire(NLockStruct *lockHandle, long timeout, unsigned char *file,
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
XplConsolePrintf("NMAP: WriteNMAPLockAcquire() called with an NULL lock handle from %s:%lu\r\n", file, line);
|
||||
Log(LOG_DEBUG, "WriteNMAPLockAcquire() called with an NULL lock handle from %s:%lu", file, line);
|
||||
#endif
|
||||
|
||||
return(NLOCK_INVALID);
|
||||
@@ -533,7 +533,7 @@ WriteNMAPLockRelease(NLockStruct *lockHandle, unsigned char *file, unsigned long
|
||||
if ((lockHandle->rLock > 0) && (lockHandle->eLock == 0) && (lockHandle->wLock == 1)) {
|
||||
;
|
||||
} else {
|
||||
XplConsolePrintf("NMAP: WriteNMAPLockRelease() called with unexpected values RLock:%lu WLock: %lu ELock: %lu from %s:%lu\r\n", lockHandle->rLock, lockHandle->wLock, lockHandle->eLock, file, line);
|
||||
Log(LOG_DEBUG, "WriteNMAPLockRelease() called with unexpected values RLock:%lu WLock: %lu ELock: %lu from %s:%lu", lockHandle->rLock, lockHandle->wLock, lockHandle->eLock, file, line);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -543,7 +543,7 @@ WriteNMAPLockRelease(NLockStruct *lockHandle, unsigned char *file, unsigned long
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
XplConsolePrintf("NMAP: WriteNMAPLockRelease() with a NULL lock handle from %s:%lu\r\n", file, line);
|
||||
Log(LOG_DEBUG, "WriteNMAPLockRelease() with a NULL lock handle from %s:%lu", file, line);
|
||||
#endif
|
||||
|
||||
return(NLOCK_INVALID);
|
||||
@@ -604,7 +604,7 @@ PurgeNMAPLockAcquire(NLockStruct *lockHandle, long timeout, unsigned char *file,
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
XplConsolePrintf("NMAP: PurgeNMAPLockAcquire() called with an NULL lock handle from %s:%lu\r\n", file, line);
|
||||
Log(LOG_DEBUG, "PurgeNMAPLockAcquire() called with an NULL lock handle from %s:%lu", file, line);
|
||||
#endif
|
||||
|
||||
return(NLOCK_INVALID);
|
||||
@@ -625,7 +625,7 @@ PurgeNMAPLockRelease(NLockStruct *lockHandle, unsigned char *file, unsigned long
|
||||
if ((lockHandle->eLock == 1) && (lockHandle->wLock == 0) && (lockHandle->rLock == 1)) {
|
||||
;
|
||||
} else {
|
||||
XplConsolePrintf("NMAP: PurgeNMAPLockAcquire() called with unexpected values RLock:%lu WLock: %lu ELock: %lu from %s:%lu\r\n", lockHandle->rLock, lockHandle->wLock, lockHandle->eLock, file, line);
|
||||
Log(LOG_DEBUG, "PurgeNMAPLockAcquire() called with unexpected values RLock:%lu WLock: %lu ELock: %lu from %s:%lu", lockHandle->rLock, lockHandle->wLock, lockHandle->eLock, file, line);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -635,7 +635,7 @@ PurgeNMAPLockRelease(NLockStruct *lockHandle, unsigned char *file, unsigned long
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
XplConsolePrintf("NMAP: PurgeNMAPLockAcquire() called with a NULL lock handle from %s:%lu\r\n", file, line);
|
||||
Log(LOG_DEBUG, "PurgeNMAPLockAcquire() called with a NULL lock handle from %s:%lu", file, line);
|
||||
#endif
|
||||
|
||||
return(NLOCK_INVALID);
|
||||
|
||||
@@ -271,17 +271,17 @@ DecodeWord(char *buf, int len, char **prevtext)
|
||||
}
|
||||
|
||||
if (BongoStreamAddCodec(stream, encoding, FALSE)) {
|
||||
printf ("Don't understand encoding %s\n", encoding);
|
||||
Log(LOG_ERROR, "Mail parser doesn't understand encoding %s", encoding);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (BongoStreamAddCodec(stream, charset, FALSE)) {
|
||||
printf("Don't understand charset %s\n", charset);
|
||||
Log(LOG_ERROR, "Mail parser doesn't understand charset %s", charset);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (BongoStreamAddCodec(stream, "UTF-8", TRUE)) {
|
||||
printf("Couldn't add UTF-8 encoder\n");
|
||||
Log(LOG_ERROR, "Mail parser couldn't convert to UTF-8");
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -1094,7 +1094,7 @@ MailParseHeaders(MailParser *parser)
|
||||
parser->p = q + 1;
|
||||
|
||||
if (-1 == ParseHeader(parser, header)) {
|
||||
printf("didn't understand header: %d: %s", header, q + 1);
|
||||
Log(LOG_ERROR, "Parsing headers, didn't understand this: %d: %s", header, q + 1);
|
||||
if (parser->p != parser->line) {
|
||||
/* nevertheless, we've got to soldier on */
|
||||
NEXTLINE(0);
|
||||
|
||||
@@ -123,9 +123,7 @@ IncomingParticipantCb(void *datap, MailHeaderName name, MailAddress *address)
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("got %s %s <%s>\n", type, address->displayName, address->address);
|
||||
#endif
|
||||
Log(LOG_DEBUG, "IPCB got %s %s <%s>\n", type, address->displayName, address->address);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+19
-19
@@ -277,7 +277,7 @@ SetupStore(const char *user, const char **storeRoot, char *path, size_t len)
|
||||
|
||||
if (stat(path, &sb)) {
|
||||
if (XplMakeDir(path)) {
|
||||
XplConsolePrintf("Error creating store: %s.\r\n", strerror(errno));
|
||||
Log(LOG_ERROR, "Error creating store directory: %s.", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -296,7 +296,7 @@ SetupStore(const char *user, const char **storeRoot, char *path, size_t len)
|
||||
CreateDatFile(path, n, len, "000000000000000c.dat") ||
|
||||
CreateDatFile(path, n, len, "000000000000000d.dat"))
|
||||
{
|
||||
XplConsolePrintf("Error creating store: %s.\r\n", strerror(errno));
|
||||
Log(LOG_ERROR, "Error creating store: %s.", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ StoreProcessDocument(StoreClient *client,
|
||||
result = MSG5005DBLIBERR;
|
||||
goto finish;
|
||||
}
|
||||
printf("processed mail with message-id %s\r\n", info->data.mail.messageId);
|
||||
Log(LOG_INFO, "Processed mail with message-id %s", info->data.mail.messageId);
|
||||
break;
|
||||
case STORE_DOCTYPE_EVENT:
|
||||
result = StoreProcessIncomingEvent(client, info, linkGuid);
|
||||
@@ -543,7 +543,7 @@ CopyMessageToMailbox(StoreClient *client,
|
||||
|
||||
StoreIOError:
|
||||
|
||||
XplConsolePrintf ("Couldn't deliver to incoming file: %s\r\n", strerror(errno));
|
||||
Log (LOG_ERROR, "Couldn't deliver mail to incoming file: %s", strerror(errno));
|
||||
if (ENOSPC == errno) {
|
||||
return DELIVER_QUOTA_EXCEEDED;
|
||||
}
|
||||
@@ -573,7 +573,7 @@ StoreCompactCollection(StoreClient *client, uint64_t collection)
|
||||
|
||||
newpath[0] = 0;
|
||||
|
||||
printf("Compacting collection " GUID_FMT "\r\n", collection);
|
||||
Log(LOG_INFO, "Compacting collection " GUID_FMT, collection);
|
||||
|
||||
if (StoreGetExclusiveLockQuiet(client, &lock, collection, 2000)) {
|
||||
return -1;
|
||||
@@ -742,8 +742,8 @@ finish:
|
||||
corrupted access, we are going to return without releasing our lock
|
||||
on the collection. FIXME - do something more graceful...
|
||||
*/
|
||||
printf("Collection " GUID_FMT " requires maintenance "
|
||||
"after failed compaction.\r\n", collection);
|
||||
Log(LOG_ERROR, "Collection " GUID_FMT " requires maintenance "
|
||||
"after failed compaction.", collection);
|
||||
|
||||
return -2;
|
||||
} else {
|
||||
@@ -981,7 +981,7 @@ ImportIncomingMail(StoreClient *client)
|
||||
info.collection = STORE_MAIL_INBOX_GUID;
|
||||
}
|
||||
} else if (-1 == dcode) {
|
||||
printf ("couldn't write to collection %s due to db error.\n",
|
||||
Log (LOG_ERROR, "Couldn't write to collection %s due to db error.",
|
||||
info.filename);
|
||||
goto finish;
|
||||
}
|
||||
@@ -1069,7 +1069,7 @@ ImportIncomingMail(StoreClient *client)
|
||||
goto finish;
|
||||
}
|
||||
|
||||
printf("Unparsable message saved in %s\n", failedPath);
|
||||
Log(LOG_ERROR, "Unparsable message saved in %s", failedPath);
|
||||
} else {
|
||||
/* success! */
|
||||
collinfo.imapuid = info.guid;
|
||||
@@ -1171,7 +1171,7 @@ cleanup:
|
||||
StoreReleaseSharedLock(client, incLock);
|
||||
|
||||
if (result < 0) {
|
||||
printf("Unable to import mail for store %s: result %d\r\n",
|
||||
Log(LOG_ERROR, "Unable to import mail for store %s: result %d",
|
||||
client->store, result);
|
||||
}
|
||||
|
||||
@@ -1269,13 +1269,13 @@ CheckJournal(DStoreHandle *handle)
|
||||
strncpy(path, filename, sizeof(path));
|
||||
p = strrchr(path, '.');
|
||||
if (!p || strcmp(".bak", p)) {
|
||||
printf ("Don't know how to restore backup file %s\n", filename);
|
||||
Log (LOG_ERROR, "Don't know how to restore backup file %s", filename);
|
||||
goto finish;
|
||||
}
|
||||
strcpy(p, ".dat");
|
||||
|
||||
if (rename(filename, path)) {
|
||||
printf ("Couldn't restore backup file %s to %s\n",
|
||||
Log (LOG_ERROR, "Couldn't restore backup file %s to %s",
|
||||
filename, path);
|
||||
goto finish;
|
||||
}
|
||||
@@ -1287,7 +1287,7 @@ CheckJournal(DStoreHandle *handle)
|
||||
stmt = NULL;
|
||||
|
||||
if (DStoreRemoveJournalEntry(handle, collection)) {
|
||||
printf ("Couldn't update journal after restoring file %s\n",
|
||||
Log (LOG_ERROR, "Couldn't update journal after restoring file %s",
|
||||
filename);
|
||||
goto finish;
|
||||
}
|
||||
@@ -1381,7 +1381,7 @@ UnselectStore(StoreClient *client)
|
||||
|
||||
index = IndexOpen(client);
|
||||
if (index) {
|
||||
printf("Optimizing index for store %s\n", client->storeName);
|
||||
Log(LOG_DEBUG, "Optimizing index for store %s", client->storeName);
|
||||
IndexOptimize(index);
|
||||
IndexClose(index);
|
||||
}
|
||||
@@ -1405,7 +1405,7 @@ UnselectStore(StoreClient *client)
|
||||
{ } /* block b/c we need this lock no matter what to free the client */
|
||||
|
||||
if (StoreWatcherRemove(client, lock)) {
|
||||
printf("Internal error removing client watch");
|
||||
Log(LOG_ERROR, "Internal error removing client watch");
|
||||
}
|
||||
|
||||
StoreReleaseExclusiveLock(client, lock);
|
||||
@@ -1542,11 +1542,11 @@ GetJson(StoreClient *client, DStoreDocInfo *info, BongoJsonNode **node)
|
||||
|
||||
fh = fopen(path, "rb");
|
||||
if (!fh) {
|
||||
printf("bongostore: Couldn't open file for doc " GUID_FMT "\n", info->guid);
|
||||
Log(LOG_ERROR, "Couldn't open file for doc " GUID_FMT, info->guid);
|
||||
goto finish;
|
||||
}
|
||||
if (0 != XplFSeek64(fh, info->start + info->headerlen, SEEK_SET)) {
|
||||
printf("bongostore: Couldn't seek to doc " GUID_FMT "\n", info->guid);
|
||||
Log(LOG_ERROR, "Couldn't seek to doc " GUID_FMT, info->guid);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@@ -1558,14 +1558,14 @@ GetJson(StoreClient *client, DStoreDocInfo *info, BongoJsonNode **node)
|
||||
if (fread(buf, 1, info->bodylen, fh) == info->bodylen) {
|
||||
buf[info->bodylen] = '\0';
|
||||
} else {
|
||||
printf("bongostore: Couldn't read doc " GUID_FMT "\n", info->guid);
|
||||
Log(LOG_ERROR, "Couldn't read doc " GUID_FMT, info->guid);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
ret = BongoJsonParseString(buf, node);
|
||||
|
||||
if (ret != BONGO_JSON_OK) {
|
||||
printf("bongostore: Couldn't parse json object %s\n", buf);
|
||||
Log(LOG_ERROR, "Couldn't parse json object %s", buf);
|
||||
}
|
||||
|
||||
finish :
|
||||
|
||||
+13
-25
@@ -23,8 +23,6 @@
|
||||
|
||||
#include <xpl.h>
|
||||
#include <memmgr.h>
|
||||
#define LOGGERNAME "store"
|
||||
#include <logger.h>
|
||||
#include <bongoutil.h>
|
||||
#include <bongoagent.h>
|
||||
#include <nmap.h>
|
||||
@@ -120,7 +118,7 @@ StoreSocketInit()
|
||||
|
||||
StoreAgent.nmapConn = ConnAlloc(FALSE);
|
||||
if (!StoreAgent.nmapConn) {
|
||||
XplConsolePrintf(AGENT_NAME ": Could not allocate connection\n");
|
||||
Log(LOG_FATAL, "Could not allocate server socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -135,14 +133,13 @@ StoreSocketInit()
|
||||
StoreAgent.nmapConn->socket = ConnServerSocket(StoreAgent.nmapConn, 2048);
|
||||
|
||||
if (XplSetEffectiveUser(MsgGetUnprivilegedUser()) < 0) {
|
||||
XplConsolePrintf("bongostore: Could not drop to unprivileged user '%s'\n",
|
||||
MsgGetUnprivilegedUser());
|
||||
Log(LOG_ERROR, "Could not drop to unprivileged user '%s'", MsgGetUnprivilegedUser());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (StoreAgent.nmapConn->socket == -1) {
|
||||
int ret = StoreAgent.nmapConn->socket;
|
||||
XplConsolePrintf("bongostore: Could not bind to port %d\n", port);
|
||||
Log(LOG_ERROR, "Could not bind to port %d", port);
|
||||
ConnFree(StoreAgent.nmapConn);
|
||||
return ret;
|
||||
}
|
||||
@@ -167,10 +164,7 @@ StoreServer(void *ignored)
|
||||
ProcessEntry,
|
||||
&StoreAgent.memPool);
|
||||
|
||||
#if VERBOSE
|
||||
/* Shutting down */
|
||||
XplConsolePrintf(AGENT_NAME ": Shutting down.\r\n");
|
||||
#endif
|
||||
Log(LOG_INFO, "Shutting down.");
|
||||
|
||||
if (StoreAgent.nmapConn) {
|
||||
ConnClose(StoreAgent.nmapConn, 1);
|
||||
@@ -181,9 +175,7 @@ StoreServer(void *ignored)
|
||||
CONN_TRACE_SHUTDOWN();
|
||||
BongoAgentShutdown(&StoreAgent.agent);
|
||||
|
||||
#if VERBOSE
|
||||
XplConsolePrintf(AGENT_NAME ": Shutdown complete\r\n");
|
||||
#endif
|
||||
Log(LOG_INFO, "Shutdown complete");
|
||||
}
|
||||
|
||||
#if defined(NETWARE) || defined(LIBC) || defined(WIN32)
|
||||
@@ -219,8 +211,7 @@ _XplServiceMain(int argc, char *argv[])
|
||||
LogStart();
|
||||
|
||||
if (XplSetEffectiveUser(MsgGetUnprivilegedUser()) < 0) {
|
||||
XplConsolePrintf("bongostore: Could not drop to unprivileged user '%s'\n",
|
||||
MsgGetUnprivilegedUser());
|
||||
Log(LOG_ERROR, "Could not drop to unprivileged user '%s'", MsgGetUnprivilegedUser());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -237,7 +228,7 @@ _XplServiceMain(int argc, char *argv[])
|
||||
startupOpts = BA_STARTUP_CONNIO | BA_STARTUP_MSGLIB | BA_STARTUP_MSGAUTH;
|
||||
ccode = BongoAgentInit(&StoreAgent.agent, AGENT_NAME, AGENT_DN, (30 * 60), startupOpts);
|
||||
if (ccode == -1) {
|
||||
XplConsolePrintf(AGENT_NAME ": Exiting.\r\n");
|
||||
Log(LOG_FATAL, "Couldn't initialize Bongo libraries");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -245,7 +236,7 @@ _XplServiceMain(int argc, char *argv[])
|
||||
cal_success = BongoCalInit(MsgGetDir(MSGAPI_DIR_DBF, NULL, 0));
|
||||
|
||||
if (! cal_success) {
|
||||
XplConsolePrintf(AGENT_NAME ": Couldn't initialize calendaring library. Exiting.\r\n");
|
||||
Log(LOG_FATAL, "Couldn't initialize calendaring library");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -254,15 +245,13 @@ _XplServiceMain(int argc, char *argv[])
|
||||
|
||||
/* Create and bind the server connection */
|
||||
if (StoreSocketInit() < 0) {
|
||||
XplConsolePrintf(AGENT_NAME ": Exiting.\n");
|
||||
Log(LOG_FATAL, "Couldn't initialize server socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Drop privs */
|
||||
if (XplSetRealUser(MsgGetUnprivilegedUser()) < 0) {
|
||||
XplConsolePrintf(AGENT_NAME ": Could not drop to unprivileged user '%s'\r\n"
|
||||
AGENT_NAME ": exiting.\n",
|
||||
MsgGetUnprivilegedUser());
|
||||
Log(LOG_FATAL, "Could not drop to unprivileged user '%s'", MsgGetUnprivilegedUser());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -277,8 +266,7 @@ _XplServiceMain(int argc, char *argv[])
|
||||
|
||||
if (!StoreAgent.threadPool) {
|
||||
BongoAgentShutdown(&StoreAgent.agent);
|
||||
XplConsolePrintf(AGENT_NAME ": Unable to create thread pool.\r\n"
|
||||
AGENT_NAME ": Exiting.\r\n");
|
||||
Log(LOG_FATAL, "Unable to create thread pool");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -286,12 +274,12 @@ _XplServiceMain(int argc, char *argv[])
|
||||
|
||||
/* setup the store guts: */
|
||||
if (StoreSetupCommands()) {
|
||||
XplConsolePrintf(AGENT_NAME ": Exiting.\r\n");
|
||||
Log(LOG_FATAL, "Couldn't setup Store internals");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (DBPoolInit()) {
|
||||
XplConsolePrintf(AGENT_NAME ": Unable to create db pool. Exiting.\r\n");
|
||||
Log(LOG_FATAL, "Unable to create db pool");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ XPL_BEGIN_C_LINKAGE
|
||||
#include <bongojson.h>
|
||||
#include <bongocal.h>
|
||||
|
||||
#define PRODUCT_SHORT_NAME "stored.nlm"
|
||||
#define LOGGERNAME "store"
|
||||
#include <logger.h>
|
||||
|
||||
/** Store stuff: **/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user