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