Skip to content

Commit

Permalink
Merge pull request #123 from mariux64/fixes
Browse files Browse the repository at this point in the history
Chaotic Chameleon.1
  • Loading branch information
donald authored Feb 21, 2022
2 parents 713212b + 06562ea commit a4b247d
Show file tree
Hide file tree
Showing 27 changed files with 335 additions and 678 deletions.
254 changes: 181 additions & 73 deletions Doxyfile

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions helper/gpu-setup
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,11 @@ job_init() {
pid=$1
uid=$2

# we have no locking here, but mxqd is single-threaded

test -d /dev/shm/mxqd/gpu_devs || die "$0: Not initialized (no dir /dev/shm/mxqd/gpu_devs)"

shopt -s nullglob
for d in /dev/shm/mxqd/gpu_devs/???; do
if [ ! -e $d/pid ]; then
if pid=$pid f=$d/pid flock $d/pid -c 'test -s $f && exit 1; echo $pid>$f'; then
for f in $(cat $d/access-files); do
case $f in
/dev/nvidia-caps/nvidia-cap*)
Expand All @@ -198,7 +196,6 @@ job_init() {
;;
esac
done
echo $pid > $d/pid
cat $d/uuid
exit
fi
Expand All @@ -213,7 +210,7 @@ job_release() {
test -d /dev/shm/mxqd/gpu_devs || die "$0: Not initialized (no dir /dev/shm/mxqd/gpu_devs)"
for d in /dev/shm/mxqd/gpu_devs/???; do
if [ -e $d/pid ]; then
test_pid=$(cat $d/pid)
test_pid="$(cat $d/pid 2>/dev/null)"
if [ "$pid" = "$test_pid" ]; then
rm $d/pid
for f in $(cat $d/access-files); do
Expand Down
9 changes: 4 additions & 5 deletions mx_flock.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#define _GNU_SOURCE

#include <sys/types.h>
Expand All @@ -21,7 +20,7 @@
# define mx_free_null(a) do { free((a)); (a) = NULL; } while(0)
#endif

static inline int _flock_open(struct mx_flock *lock, mode_t mode)
static int _flock_open(struct mx_flock *lock, mode_t mode)
{
int fd;

Expand All @@ -39,7 +38,7 @@ static inline int _flock_open(struct mx_flock *lock, mode_t mode)
return fd;
}

static inline int _flock_close(struct mx_flock *lock)
static int _flock_close(struct mx_flock *lock)
{
int res;

Expand All @@ -53,7 +52,7 @@ static inline int _flock_close(struct mx_flock *lock)
return res;
}

static inline void _flock_free(struct mx_flock *lock)
static void _flock_free(struct mx_flock *lock)
{
if (!lock)
return;
Expand Down Expand Up @@ -90,7 +89,7 @@ struct mx_flock *mx_flock(int operation, char *fmt, ...)

if (res == -1) {
mx_log_err("vasprintf(): %m");
_flock_free(lock);
free(lock);
return NULL;
}

Expand Down
20 changes: 1 addition & 19 deletions mx_getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void mx_getopt_pop_current_argument(struct mx_getopt_ctl *optctl)
optctl->_argc--;
}

void mx_getopt_pop_all_arguments(struct mx_getopt_ctl *optctl)
static void mx_getopt_pop_all_arguments(struct mx_getopt_ctl *optctl)
{
while(optctl->optind < optctl->_argc)
mx_getopt_pop_current_argument(optctl);
Expand Down Expand Up @@ -396,11 +396,6 @@ static int _mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex)
return handle_option(optctl, idx);
}

int mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex)
{
return _mx_getopt_long(optctl, optindex);
}

int mx_getopt(struct mx_getopt_ctl *optctl, int *optindex)
{
int opt;
Expand Down Expand Up @@ -455,16 +450,3 @@ int mx_getopt(struct mx_getopt_ctl *optctl, int *optindex)

return opt;
}

void mx_getopt_print_quoted(char *s)
{
putchar('\'');
while (*s) {
if (*s == '\'')
printf("'\\''");
else
putchar(*s);
s++;
}
putchar('\'');
}
4 changes: 0 additions & 4 deletions mx_getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,5 @@ struct mx_getopt_ctl {
void mx_getopt_pop_current_argument(struct mx_getopt_ctl *optctl);

int mx_getopt_init(struct mx_getopt_ctl *ctl, int argc, char **argv, struct mx_option *optv);
int mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex);
int mx_getopt(struct mx_getopt_ctl *optctl, int *optindex);

void mx_getopt_print_quoted(char *s);

#endif
6 changes: 1 addition & 5 deletions mx_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ int mx_log_printf(const char *fmt, ...)
{
int len;
int len2;
int res;
char *msg = NULL;
va_list ap;

Expand All @@ -84,15 +83,12 @@ int mx_log_printf(const char *fmt, ...)
}

len2 = fprintf(stderr, "%s\n", msg);
res = fflush(stderr);
fflush(stderr);
mx_free_null(msg);

if (len2 != len+1)
return -(errno=EIO);

if (!res)
res = 0;

return len;
}

Expand Down
2 changes: 1 addition & 1 deletion mx_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int mx_log_level_get(void);
int mx_log_level_mxlog_to_syslog(int level);
int mx_log_level_syslog_to_mxlog(int level);

int mx_log_do(int level, char *file, unsigned long line, const char *func, const char *fmt, ...) __attribute__ ((format(printf, 5, 6)));;
int mx_log_do(int level, char *file, unsigned long line, const char *func, const char *fmt, ...) __attribute__ ((format(printf, 5, 6)));
int mx_log_printf(const char *fmt, ...);

int mx_log_finish(void);
Expand Down
Loading

0 comments on commit a4b247d

Please sign in to comment.