projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into next
[paraslash.git]
/
command.c
diff --git
a/command.c
b/command.c
index b3d9855fea4488dbb1f8cfd2b70235d668134d47..1ca54da90191fd270c98b3001d16a4b5f5c04c53 100644
(file)
--- a/
command.c
+++ b/
command.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 1997-200
8
Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-200
9
Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
@@
-30,6
+30,8
@@
#include "user_list.h"
#include "server_command_list.h"
#include "afs_command_list.h"
#include "user_list.h"
#include "server_command_list.h"
#include "afs_command_list.h"
+#include "sched.h"
+#include "signal.h"
/** Commands including options must be shorter than this. */
#define MAX_COMMAND_LEN 32768
/** Commands including options must be shorter than this. */
#define MAX_COMMAND_LEN 32768
@@
-42,15
+44,8
@@
extern int mmd_mutex;
extern struct misc_meta_data *mmd;
extern struct sender senders[];
extern struct misc_meta_data *mmd;
extern struct sender senders[];
-static void dummy(int s)
+static void dummy(
__a_unused
int s)
{
{
- /*
- * At least on Solaris, SIGUSR1 is one-shot, i.e. the signal action is
- * restored to the default state once the signal handler has been
- * called.
- */
- if (s == SIGUSR1)
- signal(SIGUSR1, dummy);
}
static void mmd_dup(struct misc_meta_data *new_mmd)
}
static void mmd_dup(struct misc_meta_data *new_mmd)
@@
-113,7
+108,7
@@
static char *get_status(struct misc_meta_data *nmmd)
char *status, *flags; /* vss status info */
char *ut = uptime_str();
long offset = (nmmd->offset + 500) / 1000;
char *status, *flags; /* vss status info */
char *ut = uptime_str();
long offset = (nmmd->offset + 500) / 1000;
- struct timeval
now
;
+ struct timeval
current_time
;
struct tm mtime_tm;
/* report real status */
struct tm mtime_tm;
/* report real status */
@@
-123,7
+118,7
@@
static char *get_status(struct misc_meta_data *nmmd)
localtime_r(&nmmd->mtime, &mtime_tm);
strftime(mtime, 29, "%b %d %Y", &mtime_tm);
}
localtime_r(&nmmd->mtime, &mtime_tm);
strftime(mtime, 29, "%b %d %Y", &mtime_tm);
}
- gettimeofday(&
now
, NULL);
+ gettimeofday(&
current_time
, NULL);
ret = make_message(
"%s: %zu\n" /* file size */
"%s: %s\n" /* mtime */
ret = make_message(
"%s: %zu\n" /* file size */
"%s: %s\n" /* mtime */
@@
-146,8
+141,8
@@
static char *get_status(struct misc_meta_data *nmmd)
(long unsigned)nmmd->stream_start.tv_sec,
(long unsigned)nmmd->stream_start.tv_usec,
status_item_list[SI_CURRENT_TIME],
(long unsigned)nmmd->stream_start.tv_sec,
(long unsigned)nmmd->stream_start.tv_usec,
status_item_list[SI_CURRENT_TIME],
- (long unsigned)
now
.tv_sec,
- (long unsigned)
now
.tv_usec,
+ (long unsigned)
current_time
.tv_sec,
+ (long unsigned)
current_time
.tv_usec,
nmmd->afd.verbose_ls_output
nmmd->afd.verbose_ls_output
@@
-192,7
+187,7
@@
static int check_sender_args(int argc, char * const * argv, struct sender_comman
case SENDER_ALLOW:
if (argc != 4 && argc != 5)
return -E_COMMAND_SYNTAX;
case SENDER_ALLOW:
if (argc != 4 && argc != 5)
return -E_COMMAND_SYNTAX;
- if (!i
net_pton(AF_INET, argv[3], &scd->addr
))
+ if (!i
s_valid_ipv4_address(argv[3]
))
return -E_COMMAND_SYNTAX;
scd->netmask = 32;
if (argc == 5) {
return -E_COMMAND_SYNTAX;
scd->netmask = 32;
if (argc == 5) {
@@
-200,20
+195,13
@@
static int check_sender_args(int argc, char * const * argv, struct sender_comman
if (scd->netmask < 0 || scd->netmask > 32)
return -E_COMMAND_SYNTAX;
}
if (scd->netmask < 0 || scd->netmask > 32)
return -E_COMMAND_SYNTAX;
}
+ strncpy(scd->host, argv[3], sizeof(scd->host));
break;
case SENDER_ADD:
case SENDER_DELETE:
break;
case SENDER_ADD:
case SENDER_DELETE:
- if (argc != 4 && argc != 5)
- return -E_COMMAND_SYNTAX;
- if (!inet_pton(AF_INET, argv[3], &scd->addr))
+ if (argc != 4)
return -E_COMMAND_SYNTAX;
return -E_COMMAND_SYNTAX;
- scd->port = -1;
- if (argc == 5) {
- scd->port = atoi(argv[4]);
- if (scd->port < 0 || scd->port > 65535)
- return -E_COMMAND_SYNTAX;
- }
- break;
+ return parse_fec_url(argv[3], scd);
default:
return -E_COMMAND_SYNTAX;
}
default:
return -E_COMMAND_SYNTAX;
}
@@
-254,7
+242,7
@@
int com_sender(int fd, int argc, char * const * argv)
usleep(100 * 1000);
continue;
}
usleep(100 * 1000);
continue;
}
- m
md->sender_cmd_data = scd
;
+ m
emcpy(&mmd->sender_cmd_data, &scd, sizeof(scd))
;
mutex_unlock(mmd_mutex);
break;
}
mutex_unlock(mmd_mutex);
break;
}
@@
-280,14
+268,16
@@
int com_si(int fd, int argc, __a_unused char * const * argv)
}
ut = uptime_str();
ret = send_va_buffer(fd, "up: %s\nplayed: %u\n"
}
ut = uptime_str();
ret = send_va_buffer(fd, "up: %s\nplayed: %u\n"
- "pid: %d\n"
+ "server_pid: %d\n"
+ "afs_pid: %d\n"
"connections (active/accepted/total): %u/%u/%u\n"
"connections (active/accepted/total): %u/%u/%u\n"
- "current loglevel: %
i
\n"
+ "current loglevel: %
s
\n"
"supported audio formats: %s\n"
"supported senders: %s\n"
"%s",
ut, mmd->num_played,
(int)getppid(),
"supported audio formats: %s\n"
"supported senders: %s\n"
"%s",
ut, mmd->num_played,
(int)getppid(),
+ (int)mmd->afs_pid,
mmd->active_connections,
mmd->num_commands,
mmd->num_connects,
mmd->active_connections,
mmd->num_commands,
mmd->num_connects,
@@
-323,7
+313,7
@@
int com_stat(int fd, int argc, char * const * argv)
struct misc_meta_data tmp, *nmmd = &tmp;
char *s;
struct misc_meta_data tmp, *nmmd = &tmp;
char *s;
-
signal
(SIGUSR1, dummy);
+
para_sigaction
(SIGUSR1, dummy);
if (argc > 1)
num = atoi(argv[1]);
if (argc > 1)
num = atoi(argv[1]);
@@
-660,6
+650,14
@@
out:
}
}
+static void reset_signals(void)
+{
+ para_sigaction(SIGCHLD, SIG_IGN);
+ para_sigaction(SIGINT, SIG_DFL);
+ para_sigaction(SIGTERM, SIG_DFL);
+ para_sigaction(SIGHUP, SIG_DFL);
+}
+
/**
* Perform user authentication and execute a command.
*
/**
* Perform user authentication and execute a command.
*
@@
-699,11
+697,7
@@
__noreturn void handle_connect(int fd, const char *peername)
char *p, *command = NULL;
size_t numbytes;
char *p, *command = NULL;
size_t numbytes;
- signal(SIGCHLD, SIG_IGN);
- signal(SIGINT, SIG_DFL);
- signal(SIGTERM, SIG_DFL);
- signal(SIGHUP, SIG_DFL);
-
+ reset_signals();
/* we need a blocking fd here as recv() might return EAGAIN otherwise. */
ret = mark_fd_blocking(fd);
if (ret < 0)
/* we need a blocking fd here as recv() might return EAGAIN otherwise. */
ret = mark_fd_blocking(fd);
if (ret < 0)
@@
-792,12
+786,12
@@
__noreturn void handle_connect(int fd, const char *peername)
/* valid command and sufficient perms */
alarm(0);
argc = split_args(command, &argv, "\n");
/* valid command and sufficient perms */
alarm(0);
argc = split_args(command, &argv, "\n");
- mutex_lock(mmd_mutex);
- mmd->num_commands++;
- mutex_unlock(mmd_mutex);
PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", cmd->name, u->name,
peername);
ret = cmd->handler(fd, argc, argv);
PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", cmd->name, u->name,
peername);
ret = cmd->handler(fd, argc, argv);
+ mutex_lock(mmd_mutex);
+ mmd->num_commands++;
+ mutex_unlock(mmd_mutex);
if (ret >= 0)
goto out;
err_out:
if (ret >= 0)
goto out;
err_out: