1
0
Fork 0

fix for non-standard opendir() on reiserfs

This commit is contained in:
bagyenda 2005-05-11 05:51:57 +00:00
parent b45bd9059e
commit 38e36613c9
2 changed files with 50 additions and 44 deletions

View File

@ -846,57 +846,64 @@ static int run_dir(char *topdir, char *dir, struct Qthread_t *tlist, int num_thr
goto done; goto done;
} }
while ((dp = readdir(dirp)) != NULL) while ((dp = readdir(dirp)) != NULL) {
if ((dp->d_type & DT_REG) && struct stat st;
dp->d_name[0] == MQF && Octstr *xfname = octstr_format("%s%s", xdir, dp->d_name);
dp->d_name[1] == 'f') { int sres = stat(octstr_get_cstr(xfname), &st);
Octstr *xqf = xmake_qf(dp->d_name, dir);
MmsEnvelope *e = mms_queue_readenvelope(octstr_get_cstr(xqf),topdir, 0); octstr_destroy(xfname);
octstr_destroy(xqf); if (sres == 0 && S_ISREG(st.st_mode) &&
dp->d_name[0] == MQF &&
if (!e) dp->d_name[1] == 'f') {
continue; Octstr *xqf = xmake_qf(dp->d_name, dir);
MmsEnvelope *e = mms_queue_readenvelope(octstr_get_cstr(xqf),topdir, 0);
if (e->sendt <= tnow) {
int queued = 0; octstr_destroy(xqf);
int j = *i; /* This is the next thread to use. Checking for cycles. */
do { if (!e)
if (tlist[*i].l) { continue;
debug("queuerun", 0, "Queued to thread %d for %s%s",
*i, xdir, dp->d_name); if (e->sendt <= tnow) {
list_produce(tlist[*i].l, e); int queued = 0;
queued = 1; int j = *i; /* This is the next thread to use. Checking for cycles. */
} do {
*i = (*i+1)%num_threads; if (tlist[*i].l) {
} while (!queued && *i != j); debug("queuerun", 0, "Queued to thread %d for %s%s",
*i, xdir, dp->d_name);
if (!queued) { /* A problem. There are no sender threads! */ list_produce(tlist[*i].l, e);
free_envelope(e, 0); queued = 1;
error(0, "mms_queue_run: No active sender queues for directory %s. Quiting.",
xdir);
ret = -2;
break;
} }
} else *i = (*i+1)%num_threads;
free_envelope(e,0); /* Let go of it. */ } while (!queued && *i != j);
} else if ((dp->d_type & DT_DIR) && if (!queued) { /* A problem. There are no sender threads! */
strcmp(dp->d_name, ".") != 0 && free_envelope(e, 0);
strcmp(dp->d_name, "..") != 0) { error(0, "mms_queue_run: No active sender queues for directory %s. Quiting.",
Octstr *newdir = octstr_format("%s%s/", dir, dp->d_name); xdir);
list_append(stack, newdir); /* push it... */ ret = -2;
} break;
}
} else
free_envelope(e,0); /* Let go of it. */
} else if (sres == 0 && S_ISDIR(st.st_mode) &&
strcmp(dp->d_name, ".") != 0 &&
strcmp(dp->d_name, "..") != 0) {
Octstr *newdir = octstr_format("%s%s/", dir, dp->d_name);
list_append(stack, newdir); /* push it... */
}
}
if (dirp) closedir(dirp); if (dirp) closedir(dirp);
done: done:
if (tdir) if (tdir)
octstr_destroy(tdir); octstr_destroy(tdir);
return ret; return ret;
} }
void mms_queue_run(char *dir, void mms_queue_run(char *dir,
int (*deliver)(MmsEnvelope *), int (*deliver)(MmsEnvelope *),
double sleepsecs, int num_threads, int *rstop) double sleepsecs, int num_threads, int *rstop)
{ {
struct Qthread_t *tlist; struct Qthread_t *tlist;
int i, qstop = 0; int i, qstop = 0;

View File

@ -391,8 +391,7 @@ static int mms_load_ua_profile_cache(char *dir)
if (strcmp(dp->d_name, ".") == 0 || if (strcmp(dp->d_name, ".") == 0 ||
strcmp(dp->d_name, "..") == 0 || strcmp(dp->d_name, "..") == 0) /* A directory, skip. */
dp->d_type & DT_DIR) /* If a directory, keep going. */
continue; continue;
fname = octstr_format("%.255s/%.254s", dir, dp->d_name); fname = octstr_format("%.255s/%.254s", dir, dp->d_name);