#define TMP_SHORTER_URL_OFFSET 0xFE
#define TMP_SHORTER_URLS 0xFD
-citthread_mutex_t RSSQueueMutex; /* locks the access to the following vars: */
+pthread_mutex_t RSSQueueMutex; /* locks the access to the following vars: */
HashList *RSSQueueRooms = NULL; /* rss_room_counter */
HashList *RSSFetchUrls = NULL; /* -> rss_aggregator; ->RefCount access to be locked too. */
{
networker_save_message *Ctx = (networker_save_message *) IO->Data;
- citthread_mutex_lock(&RSSQueueMutex);
+ pthread_mutex_lock(&RSSQueueMutex);
Ctx->Cfg->RefCount --;
if (Ctx->Cfg->RefCount == 0)
UnlinkRSSAggregator(Ctx->Cfg);
}
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
CtdlFreeMessage(Ctx->Msg);
free_recipients(Ctx->recp);
return eTerminateConnection;
}
-// TODO: relink me: ExpandShortUrls(ri->description);
-
-eNextState FetchNetworkUsetableEntry(AsyncIO *IO)
+eNextState RSS_FetchNetworkUsetableEntry(AsyncIO *IO)
{
struct cdbdata *cdbut;
networker_save_message *Ctx = (networker_save_message *) IO->Data;
#ifndef DEBUG_RSS
if (cdbut != NULL) {
/* Item has already been seen */
- CtdlLogPrintf(CTDL_DEBUG, "%s has already been seen\n", ChrPtr(Ctx->MsgGUID));
+ syslog(LOG_DEBUG, "%s has already been seen\n", ChrPtr(Ctx->MsgGUID));
cdb_free(cdbut);
/* rewrite the record anyway, to update the timestamp */
Ctx->IO.CitContext = CloneContext(CC);
Ctx->IO.Terminate = FreeNetworkSaveMessage;
Ctx->IO.ShutdownAbort = AbortNetworkSaveMessage;
- QueueDBOperation(&Ctx->IO, FetchNetworkUsetableEntry);
+ QueueDBOperation(&Ctx->IO, RSS_FetchNetworkUsetableEntry);
}
}
/* translate Item into message. */
- CtdlLogPrintf(CTDL_DEBUG, "RSS: translating item...\n");
+ syslog(LOG_DEBUG, "RSS: translating item...\n");
if (ri->description == NULL) ri->description = NewStrBufPlain(HKEY(""));
StrBufSpaceToBlank(ri->description);
msg = malloc(sizeof(struct CtdlMessage));
else
{
if (FromAt)
- msg->cm_fields['P'] = SmashStrBuf(&ri->author_or_creator);
+ {
+ msg->cm_fields['A'] = SmashStrBuf(&ri->author_or_creator);
+ msg->cm_fields['P'] = strdup(msg->cm_fields['A']);
+ }
else
{
StrBufRFC2047encode(&Encoded, ri->author_or_creator);
IO->Data = Cfg;
- CtdlLogPrintf(CTDL_DEBUG, "Fetching RSS feed <%s>\n", ChrPtr(Cfg->Url));
+ syslog(LOG_DEBUG, "Fetching RSS feed <%s>\n", ChrPtr(Cfg->Url));
ParseURL(&IO->ConnectMe, Cfg->Url, 80);
CurlPrepareURL(IO->ConnectMe);
ParseRSSReply,
RSSAggregatorTerminate))
{
- CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+ syslog(LOG_DEBUG, "Unable to initialize libcurl.\n");
return 0;
}
const char *HK;
void *vData;
- citthread_mutex_lock(&RSSQueueMutex);
+ pthread_mutex_lock(&RSSQueueMutex);
rncptr->RefCount --;
if (rncptr->RefCount == 0)
{
UnlinkRSSAggregator(rncptr);
}
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
/*
At = GetNewHashPos(RSSFetchUrls, 0);
- citthread_mutex_lock(&RSSQueueMutex);
+ pthread_mutex_lock(&RSSQueueMutex);
GetHashPosFromKey(RSSFetchUrls, SKEY(rncptr->Url), At);
GetHashPos(RSSFetchUrls, At, &HKLen, &HK, &vData);
DeleteEntryFromHash(RSSFetchUrls, At);
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
DeleteHashPos(&At);
*/
const char *CfgPtr, *lPtr;
const char *Err;
- citthread_mutex_lock(&RSSQueueMutex);
+ pthread_mutex_lock(&RSSQueueMutex);
if (GetHash(RSSQueueRooms, LKEY(qrbuf->QRnumber), &vptr))
{
- CtdlLogPrintf(CTDL_DEBUG,
+ syslog(LOG_DEBUG,
"rssclient: [%ld] %s already in progress.\n",
qrbuf->QRnumber,
qrbuf->QRname);
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
return;
}
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
assoc_file_name(filename, sizeof filename, qrbuf, ctdl_netcfg_dir);
/* Only do net processing for rooms that have netconfigs */
fd = open(filename, 0);
if (fd <= 0) {
- //CtdlLogPrintf(CTDL_DEBUG, "rssclient: %s no config.\n", qrbuf->QRname);
+ //syslog(LOG_DEBUG, "rssclient: %s no config.\n", qrbuf->QRname);
return;
}
if (CtdlThreadCheckStop())
return;
if (fstat(fd, &statbuf) == -1) {
- CtdlLogPrintf(CTDL_DEBUG, "ERROR: could not stat configfile '%s' - %s\n",
+ syslog(LOG_DEBUG, "ERROR: could not stat configfile '%s' - %s\n",
filename, strerror(errno));
return;
}
if (StrBufReadBLOB(CfgData, &fd, 1, statbuf.st_size, &Err) < 0) {
close(fd);
FreeStrBuf(&CfgData);
- CtdlLogPrintf(CTDL_DEBUG, "ERROR: reading config '%s' - %s<br>\n",
+ syslog(LOG_DEBUG, "ERROR: reading config '%s' - %s<br>\n",
filename, strerror(errno));
return;
}
rncptr->Url = NewStrBuf();
StrBufExtract_NextToken(rncptr->Url, Line, &lPtr, '|');
- citthread_mutex_lock(&RSSQueueMutex);
+ pthread_mutex_lock(&RSSQueueMutex);
GetHash(RSSFetchUrls, SKEY(rncptr->Url), &vptr);
use_this_rncptr = (rss_aggregator *)vptr;
if (use_this_rncptr != NULL)
Put(use_this_rncptr->OtherQRnumbers, LKEY(qrbuf->QRnumber), QRnumber, NULL);
use_this_rncptr->roomlist_parts++;
}
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
continue;
}
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
rncptr->ItemType = RSS_UNSET;
rncptr->rooms = NewStrBufPlain(qrbuf->QRname, -1);
- citthread_mutex_lock(&RSSQueueMutex);
+ pthread_mutex_lock(&RSSQueueMutex);
Put(RSSFetchUrls, SKEY(rncptr->Url), rncptr, DeleteRssCfg);
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
}
}
}
if (Count != NULL)
{
Count->QRnumber = qrbuf->QRnumber;
- citthread_mutex_lock(&RSSQueueMutex);
- CtdlLogPrintf(CTDL_DEBUG, "rssclient: [%ld] %s now starting.\n",
+ pthread_mutex_lock(&RSSQueueMutex);
+ syslog(LOG_DEBUG, "rssclient: [%ld] %s now starting.\n",
qrbuf->QRnumber, qrbuf->QRname);
Put(RSSQueueRooms, LKEY(qrbuf->QRnumber), Count, NULL);
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
}
FreeStrBuf(&CfgData);
FreeStrBuf(&CfgType);
long len;
const char *Key;
+ /* Run no more than once every 15 minutes. * /
+ if ((time(NULL) - last_run) < 900) {
+ return;
+ }
+*/
/*
* This is a simple concurrency check to make sure only one rssclient run
* is done at a time. We could do this with a mutex, but since we
if (doing_rssclient) return;
doing_rssclient = 1;
- CtdlLogPrintf(CTDL_DEBUG, "rssclient started\n");
+ syslog(LOG_DEBUG, "rssclient started\n");
CtdlForEachRoom(rssclient_scan_room, NULL);
- citthread_mutex_lock(&RSSQueueMutex);
+ pthread_mutex_lock(&RSSQueueMutex);
it = GetNewHashPos(RSSFetchUrls, 0);
while (GetNextHashPos(RSSFetchUrls, it, &len, &Key, &vrptr) &&
UnlinkRSSAggregator(rptr);
}
DeleteHashPos(&it);
- citthread_mutex_unlock(&RSSQueueMutex);
+ pthread_mutex_unlock(&RSSQueueMutex);
- CtdlLogPrintf(CTDL_DEBUG, "rssclientscheduler ended\n");
+ syslog(LOG_DEBUG, "rssclient ended\n");
doing_rssclient = 0;
return;
}
void rss_cleanup(void)
{
- citthread_mutex_destroy(&RSSQueueMutex);
+ /* citthread_mutex_destroy(&RSSQueueMutex); TODO */
DeleteHash(&RSSFetchUrls);
DeleteHash(&RSSQueueRooms);
}
{
if (threading)
{
- citthread_mutex_init(&RSSQueueMutex, NULL);
+ pthread_mutex_init(&RSSQueueMutex, NULL);
RSSQueueRooms = NewHash(1, lFlathash);
RSSFetchUrls = NewHash(1, NULL);
- CtdlLogPrintf(CTDL_INFO, "%s\n", curl_version());
+ syslog(LOG_INFO, "%s\n", curl_version());
CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER);
CtdlRegisterCleanupHook(rss_cleanup);
}