Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libpromises/conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ static void AddSimpleUidItem(UidList ** uidlist, uid_t uid, char *uidname)

ulp->uid = uid;

if (uid == CF_UNKNOWN_OWNER) /* unknown user */
if (uid == CF_UNKNOWN_OWNER && uidname != NULL) /* unknown user */
{
ulp->uidname = xstrdup(uidname);
}
Expand Down Expand Up @@ -1019,7 +1019,7 @@ static void AddSimpleGidItem(GidList ** gidlist, gid_t gid, char *gidname)

glp->gid = gid;

if (gid == CF_UNKNOWN_GROUP) /* unknown group */
if (gid == CF_UNKNOWN_GROUP && gidname != NULL) /* unknown group */
{
glp->gidname = xstrdup(gidname);
}
Expand Down
14 changes: 6 additions & 8 deletions libpromises/evalfunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -8532,7 +8532,7 @@ struct IsReadableThreadData
pthread_cond_t cond;
pthread_mutex_t mutex;
const char *path;
FnCallResult result;
bool success;
};

static void *IsReadableThreadRoutine(void *data)
Expand All @@ -8549,7 +8549,7 @@ static void *IsReadableThreadRoutine(void *data)
GetErrorStrFromCode(ret));
}

thread_data->result = FnReturnContext(false);
thread_data->success = false;

// Allow main thread to require lock on pthread_cond_timedwait(3)
ret = pthread_mutex_unlock(&thread_data->mutex);
Expand All @@ -8574,7 +8574,7 @@ static void *IsReadableThreadRoutine(void *data)
else
{
close(fd);
thread_data->result = FnReturnContext(true);
thread_data->success = true;
}

ret = pthread_cond_signal(&(thread_data->cond));
Expand Down Expand Up @@ -8676,13 +8676,13 @@ static FnCallResult FnCallIsReadable(ARG_UNUSED EvalContext *const ctx,
return FnFailure();
}

FnCallResult result;
bool success = false;
// Wait on thread to finish or timeout
ret = ThreadWait(&thread_data.cond, &thread_data.mutex, timeout);
switch (ret)
{
case 0: // Thread finished in time
result = thread_data.result;
success = thread_data.success;
break;

case ETIMEDOUT: // Thread timed out
Expand All @@ -8696,8 +8696,6 @@ static FnCallResult FnCallIsReadable(ARG_UNUSED EvalContext *const ctx,
Log(LOG_LEVEL_ERR, "Failed to cancel thread");
return FnFailure();
}

result = FnReturnContext(false);
break;

default:
Expand Down Expand Up @@ -8727,7 +8725,7 @@ static FnCallResult FnCallIsReadable(ARG_UNUSED EvalContext *const ctx,
Log(LOG_LEVEL_DEBUG, "Thread was canceled");
}

return result;
return FnReturnContext(success);
}

/*********************************************************************/
Expand Down
Loading