mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-12 20:27:19 +00:00
fix lots of BS
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@716 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
21d221a10f
commit
7665bf3e8e
@ -906,6 +906,11 @@ SWITCH_DECLARE(FILE *) switch_core_get_console(void);
|
|||||||
\brief Launch a thread
|
\brief Launch a thread
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread *, void*), void *obj, switch_memory_pool *pool);
|
SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread *, void*), void *obj, switch_memory_pool *pool);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Initiate Globals
|
||||||
|
*/
|
||||||
|
SWITCH_DECLARE(void) switch_core_set_globals(void);
|
||||||
///\}
|
///\}
|
||||||
|
|
||||||
#ifdef USE_PERL
|
#ifdef USE_PERL
|
||||||
|
@ -42,9 +42,9 @@ extern "C" {
|
|||||||
#include <switch_platform.h>
|
#include <switch_platform.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define SEP "\\"
|
#define SWITCH_PATH_SEPARATOR "\\"
|
||||||
#else
|
#else
|
||||||
#define SEP "/"
|
#define SWITCH_PATH_SEPARATOR "/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWITCH_PREFIX_DIR
|
#ifndef SWITCH_PREFIX_DIR
|
||||||
@ -52,23 +52,23 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWITCH_MOD_DIR
|
#ifndef SWITCH_MOD_DIR
|
||||||
#define SWITCH_MOD_DIR SWITCH_PREFIX_DIR SEP "mod"
|
#define SWITCH_MOD_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "mod"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWITCH_CONF_DIR
|
#ifndef SWITCH_CONF_DIR
|
||||||
#define SWITCH_CONF_DIR SWITCH_PREFIX_DIR SEP "conf"
|
#define SWITCH_CONF_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "conf"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWITCH_LOG_DIR
|
#ifndef SWITCH_LOG_DIR
|
||||||
#define SWITCH_LOG_DIR SWITCH_PREFIX_DIR SEP "log"
|
#define SWITCH_LOG_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "log"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWITCH_DB_DIR
|
#ifndef SWITCH_DB_DIR
|
||||||
#define SWITCH_DB_DIR SWITCH_PREFIX_DIR SEP "db"
|
#define SWITCH_DB_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "db"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWITCH_SCRIPT_DIR
|
#ifndef SWITCH_SCRIPT_DIR
|
||||||
#define SWITCH_SCRIPT_DIR SWITCH_PREFIX_DIR SEP "scripts"
|
#define SWITCH_SCRIPT_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "scripts"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct switch_directories {
|
struct switch_directories {
|
||||||
|
@ -61,7 +61,7 @@ endif
|
|||||||
|
|
||||||
CFLAGS += -I$(BASE)/libs/mozilla/js/src -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/js/src -I$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -I$(OS_CONFIG)_DBG.OBJ
|
CFLAGS += -I$(BASE)/libs/mozilla/js/src -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/js/src -I$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -I$(OS_CONFIG)_DBG.OBJ
|
||||||
LDFLAGS +=-DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -lteletone
|
LDFLAGS +=-DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -lteletone
|
||||||
OBJS=$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a
|
OBJS=$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a -lcurl
|
||||||
LINKER=$(CC)
|
LINKER=$(CC)
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ struct teletone_obj {
|
|||||||
switch_core_session *session;
|
switch_core_session *session;
|
||||||
switch_codec codec;
|
switch_codec codec;
|
||||||
switch_buffer *audio_buffer;
|
switch_buffer *audio_buffer;
|
||||||
|
switch_buffer *loop_buffer;
|
||||||
switch_memory_pool *pool;
|
switch_memory_pool *pool;
|
||||||
switch_timer *timer;
|
switch_timer *timer;
|
||||||
switch_timer timer_base;
|
switch_timer timer_base;
|
||||||
@ -882,6 +883,7 @@ static JSBool teletone_on_dtmf(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
|||||||
static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||||
{
|
{
|
||||||
struct teletone_obj *tto = JS_GetPrivate(cx, obj);
|
struct teletone_obj *tto = JS_GetPrivate(cx, obj);
|
||||||
|
int32 loops = 0;
|
||||||
|
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
char *script;
|
char *script;
|
||||||
@ -893,7 +895,23 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||||||
switch_core_thread_session thread_session;
|
switch_core_thread_session thread_session;
|
||||||
switch_channel *channel;
|
switch_channel *channel;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
if (!JS_ValueToInt32(cx, argv[1], &loops)) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Convert to INT\n");
|
||||||
|
return JS_FALSE;
|
||||||
|
}
|
||||||
|
loops--;
|
||||||
|
if (!tto->loop_buffer) {
|
||||||
|
switch_buffer_create(tto->pool, &tto->loop_buffer, SWITCH_RECCOMMENDED_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tto->audio_buffer) {
|
||||||
|
switch_buffer_zero(tto->audio_buffer);
|
||||||
|
}
|
||||||
|
if (tto->loop_buffer) {
|
||||||
|
switch_buffer_zero(tto->loop_buffer);
|
||||||
|
}
|
||||||
tto->ts.debug = 1;
|
tto->ts.debug = 1;
|
||||||
tto->ts.debug_stream = switch_core_get_console();
|
tto->ts.debug_stream = switch_core_get_console();
|
||||||
|
|
||||||
@ -943,9 +961,23 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((write_frame.datalen = switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
||||||
|
if (loops > 0) {
|
||||||
|
switch_buffer *tmp;
|
||||||
|
|
||||||
|
/* Switcharoo*/
|
||||||
|
tmp = tto->audio_buffer;
|
||||||
|
tto->audio_buffer = tto->loop_buffer;
|
||||||
|
tto->loop_buffer = tmp;
|
||||||
|
loops--;
|
||||||
|
/* try again */
|
||||||
if ((write_frame.datalen = switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
if ((write_frame.datalen = switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
write_frame.samples = write_frame.datalen / 2;
|
write_frame.samples = write_frame.datalen / 2;
|
||||||
for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
|
for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
|
||||||
@ -954,6 +986,9 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tto->loop_buffer && loops) {
|
||||||
|
switch_buffer_write(tto->loop_buffer, write_frame.data, write_frame.datalen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tto->timer) {
|
if (tto->timer) {
|
||||||
|
43
src/switch.c
43
src/switch.c
@ -65,34 +65,30 @@ int main(int argc, char *argv[])
|
|||||||
char *lfile = "freeswitch.log";
|
char *lfile = "freeswitch.log";
|
||||||
char *pfile = "freeswitch.pid";
|
char *pfile = "freeswitch.pid";
|
||||||
char path[256] = "";
|
char path[256] = "";
|
||||||
|
char *ppath = NULL;
|
||||||
char *err = NULL;
|
char *err = NULL;
|
||||||
switch_event *event;
|
switch_event *event;
|
||||||
int bg = 0;
|
int bg = 0;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
char sep = '\\';
|
|
||||||
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
||||||
#else
|
#else
|
||||||
char sep = '/';
|
|
||||||
int pid;
|
int pid;
|
||||||
nice(-20);
|
nice(-20);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (switch_core_init(NULL) != SWITCH_STATUS_SUCCESS) {
|
|
||||||
fprintf(stderr, "Cannot Initilize\n");
|
|
||||||
return 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
if (argv[1] && !strcmp(argv[1], "-stop")) {
|
if (argv[1] && !strcmp(argv[1], "-stop")) {
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.conf_dir, sep, pfile);
|
switch_core_set_globals();
|
||||||
|
snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
|
||||||
if ((f = fopen(path, "r")) == 0) {
|
if ((f = fopen(path, "r")) == 0) {
|
||||||
fprintf(stderr, "Cannot open pid file %s.\n", path);
|
fprintf(stderr, "Cannot open pid file %s.\n", path);
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
fscanf(f, "%d", &pid);
|
fscanf(f, "%d", &pid);
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
|
fprintf(stderr, "Killing %d\n", (int) pid);
|
||||||
kill(pid, SIGTERM);
|
kill(pid, SIGTERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +97,23 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (argv[1] && !strcmp(argv[1], "-nc")) {
|
||||||
|
bg++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bg) {
|
||||||
|
//snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.log_dir, sep, lfile);
|
||||||
|
ppath = lfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (switch_core_init(ppath) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "Cannot Initilize\n");
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* set signal handlers */
|
/* set signal handlers */
|
||||||
(void) signal(SIGINT, (void *) handle_SIGINT);
|
(void) signal(SIGINT, (void *) handle_SIGINT);
|
||||||
#ifdef SIGPIPE
|
#ifdef SIGPIPE
|
||||||
@ -111,9 +124,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (argv[1] && !strcmp(argv[1], "-nc")) {
|
|
||||||
bg++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bg) {
|
if (bg) {
|
||||||
(void) signal(SIGHUP, (void *) handle_SIGHUP);
|
(void) signal(SIGHUP, (void *) handle_SIGHUP);
|
||||||
@ -129,7 +140,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.conf_dir, sep, pfile);
|
snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
|
||||||
if ((f = fopen(path, "w")) == 0) {
|
if ((f = fopen(path, "w")) == 0) {
|
||||||
fprintf(stderr, "Cannot open pid file %s.\n", path);
|
fprintf(stderr, "Cannot open pid file %s.\n", path);
|
||||||
return 255;
|
return 255;
|
||||||
@ -138,12 +149,6 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(f, "%d", getpid());
|
fprintf(f, "%d", getpid());
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (bg) {
|
|
||||||
snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.conf_dir, sep, lfile);
|
|
||||||
if (switch_core_set_console(path) != SWITCH_STATUS_SUCCESS) {
|
|
||||||
err = "Cannot open log file\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
@ -165,7 +170,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "freeswitch Version %s Started\n\n", SWITCH_VERSION_FULL);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "freeswitch Version %s Started\n\n", SWITCH_VERSION_FULL);
|
||||||
snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.conf_dir, sep, pfile);
|
snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
|
||||||
|
|
||||||
if (bg) {
|
if (bg) {
|
||||||
bg = 0;
|
bg = 0;
|
||||||
|
@ -2180,15 +2180,13 @@ static void core_event_handler(switch_event *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status) switch_core_init(char *console)
|
SWITCH_DECLARE(void) switch_core_set_globals(void)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define BUFSIZE 50
|
#define BUFSIZE 50
|
||||||
char lpPathBuffer[BUFSIZE];
|
char lpPathBuffer[BUFSIZE];
|
||||||
DWORD dwBufSize=BUFSIZE;
|
DWORD dwBufSize=BUFSIZE;
|
||||||
#endif
|
#endif
|
||||||
memset(&runtime, 0, sizeof(runtime));
|
|
||||||
|
|
||||||
SWITCH_GLOBAL_dirs.base_dir = SWITCH_PREFIX_DIR;
|
SWITCH_GLOBAL_dirs.base_dir = SWITCH_PREFIX_DIR;
|
||||||
SWITCH_GLOBAL_dirs.mod_dir = SWITCH_MOD_DIR;
|
SWITCH_GLOBAL_dirs.mod_dir = SWITCH_MOD_DIR;
|
||||||
SWITCH_GLOBAL_dirs.conf_dir = SWITCH_CONF_DIR;
|
SWITCH_GLOBAL_dirs.conf_dir = SWITCH_CONF_DIR;
|
||||||
@ -2205,12 +2203,24 @@ SWITCH_DECLARE(switch_status) switch_core_init(char *console)
|
|||||||
SWITCH_GLOBAL_dirs.temp_dir = "/tmp/";
|
SWITCH_GLOBAL_dirs.temp_dir = "/tmp/";
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_status) switch_core_init(char *console)
|
||||||
|
{
|
||||||
|
|
||||||
|
memset(&runtime, 0, sizeof(runtime));
|
||||||
|
|
||||||
|
switch_core_set_globals();
|
||||||
|
|
||||||
#ifdef EMBED_PERL
|
#ifdef EMBED_PERL
|
||||||
PerlInterpreter *my_perl;
|
PerlInterpreter *my_perl;
|
||||||
#endif
|
#endif
|
||||||
if(console) {
|
if(console) {
|
||||||
|
if (*console != '/') {
|
||||||
|
char path[265];
|
||||||
|
snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, console);
|
||||||
|
console = path;
|
||||||
|
}
|
||||||
switch_core_set_console(console);
|
switch_core_set_console(console);
|
||||||
} else {
|
} else {
|
||||||
runtime.console = stdout;
|
runtime.console = stdout;
|
||||||
|
@ -162,6 +162,10 @@ static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread *thread, void
|
|||||||
switch_event_deliver(&out_event);
|
switch_event_deliver(&out_event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (THREAD_RUNNING < 0) {
|
||||||
|
THREAD_RUNNING--;
|
||||||
|
}
|
||||||
switch_yield(1000);
|
switch_yield(1000);
|
||||||
}
|
}
|
||||||
THREAD_RUNNING = 0;
|
THREAD_RUNNING = 0;
|
||||||
@ -230,10 +234,18 @@ SWITCH_DECLARE(switch_status) switch_event_reserve_subclass_detailed(char *owner
|
|||||||
|
|
||||||
SWITCH_DECLARE(switch_status) switch_event_shutdown(void)
|
SWITCH_DECLARE(switch_status) switch_event_shutdown(void)
|
||||||
{
|
{
|
||||||
|
int x = 0, last = 0;
|
||||||
|
|
||||||
|
if (THREAD_RUNNING > 0) {
|
||||||
THREAD_RUNNING = -1;
|
THREAD_RUNNING = -1;
|
||||||
|
|
||||||
while (THREAD_RUNNING) {
|
while (x < 100 && THREAD_RUNNING) {
|
||||||
switch_yield(1000);
|
switch_yield(1000);
|
||||||
|
if (THREAD_RUNNING == last) {
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
last = THREAD_RUNNING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user