mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 21:51:30 +00:00
fixed alarm subsystem and added uwsgi.alarm to the JVM
This commit is contained in:
+1
-1
@@ -267,7 +267,7 @@ void uwsgi_alarms_init() {
|
||||
}
|
||||
|
||||
void uwsgi_alarm_thread_start() {
|
||||
// start the alarm_threa
|
||||
// start the alarm_thread
|
||||
uwsgi.alarm_thread = uwsgi_thread_new(uwsgi_alarm_thread_loop);
|
||||
if (!uwsgi.alarm_thread) {
|
||||
uwsgi_log("unable to spawn alarm thread\n");
|
||||
|
||||
@@ -371,9 +371,6 @@ int master_loop(char **argv, char **environ) {
|
||||
|
||||
}
|
||||
|
||||
uwsgi_alarm_thread_start();
|
||||
uwsgi_exceptions_handler_thread_start();
|
||||
|
||||
#ifdef UWSGI_SSL
|
||||
uwsgi_start_legions();
|
||||
#endif
|
||||
|
||||
@@ -2541,6 +2541,9 @@ next:
|
||||
#endif
|
||||
|
||||
if (uwsgi.master_process) {
|
||||
// initialize threads with shared state
|
||||
uwsgi_alarm_thread_start();
|
||||
uwsgi_exceptions_handler_thread_start();
|
||||
// initialize a mutex to avoid glibc problem with pthread+fork()
|
||||
if (uwsgi.threaded_logger) {
|
||||
pthread_mutex_init(&uwsgi.threaded_logger_lock, NULL);
|
||||
|
||||
@@ -93,6 +93,17 @@ JNIEXPORT jobject JNICALL uwsgi_jvm_api_cache_get(JNIEnv *env, jclass c, jstring
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL uwsgi_jvm_api_alarm(JNIEnv *env, jclass c, jstring alarm, jstring msg) {
|
||||
|
||||
char *c_alarm = uwsgi_jvm_str2c(alarm);
|
||||
size_t c_msg_len = uwsgi_jvm_strlen(msg);
|
||||
char *c_msg = uwsgi_jvm_str2c(msg);
|
||||
uwsgi_alarm_trigger(c_alarm, c_msg, c_msg_len);
|
||||
uwsgi_jvm_release_chars(msg, c_msg);
|
||||
uwsgi_jvm_release_chars(alarm, c_alarm);
|
||||
|
||||
}
|
||||
|
||||
static JNINativeMethod uwsgi_jvm_api_methods[] = {
|
||||
{"register_signal", "(ILjava/lang/String;Luwsgi$SignalHandler;)V", (void *) &uwsgi_jvm_api_register_signal},
|
||||
{"register_rpc", "(Ljava/lang/String;Luwsgi$RpcFunction;)V", (void *) &uwsgi_jvm_api_register_rpc},
|
||||
@@ -102,6 +113,7 @@ static JNINativeMethod uwsgi_jvm_api_methods[] = {
|
||||
{"lock", "(I)V", (void *) &uwsgi_jvm_api_lock},
|
||||
{"unlock", "(I)V", (void *) &uwsgi_jvm_api_unlock},
|
||||
{"cache_get", "(Ljava/lang/String;)[B", (void *) &uwsgi_jvm_api_cache_get},
|
||||
{"alarm", "(Ljava/lang/String;Ljava/lang/String;)V", (void *) &uwsgi_jvm_api_alarm},
|
||||
};
|
||||
|
||||
JNIEXPORT jint JNICALL uwsgi_jvm_request_body_read(JNIEnv *env, jobject o) {
|
||||
|
||||
@@ -28,5 +28,14 @@ public class uwsgi {
|
||||
public static native void unlock(int locknum);
|
||||
|
||||
public static native byte[] cache_get(String key);
|
||||
public static native byte[] cache_get(String key, String cache);
|
||||
public static native void cache_set(String key, byte[] value);
|
||||
public static native void cache_update(String key, byte[] value);
|
||||
public static native void cache_set(String key, byte[] value, int expires);
|
||||
public static native void cache_update(String key, byte[] value, int expires);
|
||||
public static native void cache_set(String key, byte[] value, int expires, String cache);
|
||||
public static native void cache_update(String key, byte[] value, int expires, String cache);
|
||||
|
||||
public static native void alarm(String alarm, String msg);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user