Author: mturk
Date: Thu Feb 11 16:43:36 2010
New Revision: 909069
URL: http://svn.apache.org/viewvc?rev=909069&view=rev
Log:
Fix DAEMON-47 by implementing slightly modified patches.
Note that this will require reviewing
Added:
commons/proper/daemon/trunk/src/native/unix/native/locks.c (with props)
commons/proper/daemon/trunk/src/native/unix/native/locks.h (with props)
Modified:
commons/proper/daemon/trunk/src/native/nt/moni/vdmoniadm.c
commons/proper/daemon/trunk/src/native/nt/moni/vdmonisvc.c
commons/proper/daemon/trunk/src/native/unix/native/Makefile.in
commons/proper/daemon/trunk/src/native/unix/native/arguments.c
commons/proper/daemon/trunk/src/native/unix/native/dso-dlfcn.c
commons/proper/daemon/trunk/src/native/unix/native/dso.h
commons/proper/daemon/trunk/src/native/unix/native/help.h
commons/proper/daemon/trunk/src/native/unix/native/java.c
commons/proper/daemon/trunk/src/native/unix/native/java.h
commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c
commons/proper/daemon/trunk/src/native/unix/native/jsvc.h
commons/proper/daemon/trunk/src/native/unix/native/location.h
commons/proper/daemon/trunk/src/native/unix/native/signals.c
Modified: commons/proper/daemon/trunk/src/native/nt/moni/vdmoniadm.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/moni/vdmoniadm.c?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/moni/vdmoniadm.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/moni/vdmoniadm.c Thu Feb 11
16:43:36 2010
@@ -191,11 +191,11 @@
}
/* Yes/No dialog box */
-LRESULT APIENTRY StopYesNo(
+BOOL CALLBACK StopYesNo(
HWND hDlg, /* window handle of the dialog box */
UINT message, /* type of message */
- UINT wParam, /* message-specific information */
- LONG lParam)
+ WPARAM wParam, /* message-specific information */
+ LPARAM lParam)
{
SERVICE_STATUS svcStatus;
@@ -217,11 +217,11 @@
UNREFERENCED_PARAMETER(lParam);
}
/* Please wait stopping dialog box */
-LRESULT APIENTRY PleaseWait(
+BOOL CALLBACK PleaseWait(
HWND hDlg, /* window handle of the dialog box */
UINT message, /* type of message */
- UINT wParam, /* message-specific information */
- LONG lParam)
+ WPARAM wParam, /* message-specific information */
+ LPARAM lParam)
{
switch (message) {
@@ -241,11 +241,11 @@
return (FALSE); /* Didn't process a message
*/
UNREFERENCED_PARAMETER(lParam);
}
-LRESULT APIENTRY StartYesNo(
+BOOL CALLBACK StartYesNo(
HWND hDlg, /* window handle of the dialog box */
UINT message, /* type of message */
- UINT wParam, /* message-specific information */
- LONG lParam)
+ WPARAM wParam, /* message-specific information */
+ LPARAM lParam)
{
switch (message) {
@@ -285,7 +285,7 @@
/* Display the menu */
-void ShowMenu(HWND hWnd)
+void ShowMenu(HWND hWnd)
{
HMENU hMenu,hMenu1;
POINT point;
@@ -368,11 +368,11 @@
*
*\***************************************************************************/
-LONG APIENTRY MainWndProc(
+LRESULT CALLBACK MainWndProc(
HWND hWnd, /* window handle */
UINT message, /* type of message */
- UINT wParam, /* additional information */
- LONG lParam) /* additional information */
+ WPARAM wParam, /* additional information */
+ LPARAM lParam) /* additional information */
{
SERVICE_STATUS svcStatus;
@@ -576,7 +576,7 @@
/* main window.
*/
wc.style = 0; /* Class style(s).
*/
- wc.lpfnWndProc = (WNDPROC)MainWndProc;/* Function to retrieve messages for
*/
+ wc.lpfnWndProc = MainWndProc; /* Function to retrieve messages for
*/
/* windows of this class.
*/
wc.cbClsExtra = 0; /* No per-class extra data.
*/
wc.cbWndExtra = 0; /* No per-window extra data.
*/
Modified: commons/proper/daemon/trunk/src/native/nt/moni/vdmonisvc.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/moni/vdmonisvc.c?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/moni/vdmonisvc.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/moni/vdmonisvc.c Thu Feb 11
16:43:36 2010
@@ -69,7 +69,7 @@
{
TCHAR szMsg[256];
HANDLE hEventSource;
- LPTSTR lpszStrings[2];
+ LPCTSTR lpszStrings[2];
dwErr = GetLastError();
Modified: commons/proper/daemon/trunk/src/native/unix/native/Makefile.in
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/Makefile.in?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/Makefile.in (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/Makefile.in Thu Feb 11
16:43:36 2010
@@ -28,6 +28,7 @@
java.o \
location.o \
replace.o \
+ locks.o \
signals.o
all: jsvc libservice.a
Modified: commons/proper/daemon/trunk/src/native/unix/native/arguments.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/arguments.c?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/arguments.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/arguments.c Thu Feb 11
16:43:36 2010
@@ -200,7 +200,7 @@
} else if (strcmp(argv[x],"-procname") == 0) {
args->procname = optional(argc, argv, x++);
- if( args->procname == NULL) {
+ if (args->procname == NULL) {
log_error("Invalid process name specified");
return (NULL);
}
Modified: commons/proper/daemon/trunk/src/native/unix/native/dso-dlfcn.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/dso-dlfcn.c?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/dso-dlfcn.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/dso-dlfcn.c Thu Feb 11
16:43:36 2010
@@ -26,7 +26,7 @@
#endif /* ifdef OS_LINUX */
/* Initialize all DSO stuff */
-bool dso_init() {
+bool dso_init(void) {
return(true);
}
@@ -49,7 +49,7 @@
}
/* Return the error message from dlopen */
-char *dso_error() {
+char *dso_error(void) {
return(dlerror());
}
Modified: commons/proper/daemon/trunk/src/native/unix/native/dso.h
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/dso.h?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/dso.h (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/dso.h Thu Feb 11
16:43:36 2010
@@ -15,6 +15,9 @@
limitations under the License.
*/
/* @version $Id$ */
+#ifndef __JSVC_DSO_H__
+#define __JSVC_DSO_H__
+
#include "jsvc.h"
/**
@@ -29,3 +32,7 @@
dso_handle dso_link(const char *pth);
bool dso_unlink(dso_handle lib);
void *dso_symbol(dso_handle lib, const char *nam);
+char *dso_error(void);
+
+#endif /* __JSVC_DSO_H__ */
+
Modified: commons/proper/daemon/trunk/src/native/unix/native/help.h
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/help.h?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/help.h (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/help.h Thu Feb 11
16:43:36 2010
@@ -15,4 +15,10 @@
limitations under the License.
*/
/* @version $Id$ */
+#ifndef __JSVC_HELP_H__
+#define __JSVC_HELP_H__
+
void help(home_data *data);
+
+#endif /* __JSVC_HELP_H__ */
+
Modified: commons/proper/daemon/trunk/src/native/unix/native/java.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/java.c?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/java.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/java.c Thu Feb 11
16:43:36 2010
@@ -45,8 +45,8 @@
if (reload==TRUE) main_reload();
else main_shutdown();
}
-/* Automaticly restart when the JVM crashes */
-static void java_abort123()
+/* Automatically restart when the JVM crashes */
+static void java_abort123(void)
{
exit(123);
}
Modified: commons/proper/daemon/trunk/src/native/unix/native/java.h
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/java.h?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/java.h (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/java.h Thu Feb 11
16:43:36 2010
@@ -15,6 +15,8 @@
limitations under the License.
*/
/* @version $Id$ */
+#ifndef __JSVC_JAVA_H__
+#define __JSVC_JAVA_H__
#define LOADER "org/apache/commons/daemon/support/DaemonLoader"
@@ -27,3 +29,6 @@
bool java_version(void);
bool java_check(arg_data *args);
bool JVM_destroy(int exit);
+
+#endif /* __JSVC_JAVA_H__ */
+
Modified: commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c Thu Feb 11
16:43:36 2010
@@ -44,7 +44,7 @@
static mode_t envmask; /* mask to create the files */
-pid_t controlled=0; /* the son process pid */
+pid_t controlled=0; /* the child process pid */
static bool stopping=false;
static bool doreload=false;
static void (*handler_int)(int)=NULL;
@@ -267,7 +267,7 @@
}
#ifdef OS_CYGWIN
-static void cygwincontroller() {
+static void cygwincontroller(void) {
raise(SIGTERM);
}
#endif
@@ -378,8 +378,8 @@
* /tmp/pid.jsvc_up
* Notes:
* we fork several times
- * 1 - to be a daemon before the setsid(), the son is the controler process.
- * 2 - to start the JVM in the son process. (whose pid is stored in pidfile).
+ * 1 - to be a daemon before the setsid(), the child is the controler process.
+ * 2 - to start the JVM in the child process. (whose pid is stored in pidfile).
*/
static int check_tmp_file(arg_data *args) {
int pid;
@@ -492,7 +492,7 @@
}
/*
- * son process logic.
+ * child process logic.
*/
static int child(arg_data *args, home_data *data, uid_t uid, gid_t gid) {
@@ -517,7 +517,7 @@
#ifdef OS_LINUX
/* setuid()/setgid() only apply the current thread so we must do it now */
if (linuxset_user_group(args->user,uid,gid)!=0)
- return(4);
+ return(4);
#endif
/* Initialize the Java VM */
if (java_init(args,data)!=true) {
Modified: commons/proper/daemon/trunk/src/native/unix/native/jsvc.h
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/jsvc.h?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/jsvc.h (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/jsvc.h Thu Feb 11
16:43:36 2010
@@ -43,6 +43,8 @@
#include "dso.h"
#include "java.h"
#include "help.h"
+#include "signals.h"
+#include "locks.h"
int main(int argc, char *argv[]);
void main_reload(void);
Modified: commons/proper/daemon/trunk/src/native/unix/native/location.h
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/location.h?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/location.h (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/location.h Thu Feb 11
16:43:36 2010
@@ -15,9 +15,15 @@
limitations under the License.
*/
/* @version $Id$ */
+#ifndef __JSVC_LOCATION_H__
+#define __JSVC_LOCATION_H__
+
#include "jsvc.h"
extern char *location_home[];
extern char *location_jvm_cfg[];
extern char *location_jvm_default[];
extern char *location_jvm_configured[];
+
+#endif /* __JSVC_LOCATION_H__ */
+
Added: commons/proper/daemon/trunk/src/native/unix/native/locks.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/locks.c?rev=909069&view=auto
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/locks.c (added)
+++ commons/proper/daemon/trunk/src/native/unix/native/locks.c Thu Feb 11
16:43:36 2010
@@ -0,0 +1,49 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id$ */
+
+/*
+ * as Cygwin does not support lockf, jsvc uses fcntl to emulate it.
+ */
+#ifdef OS_CYGWIN
+#include "jsvc.h"
+#include <sys/fcntl.h>
+
+/*
+ * File locking routine
+ */
+int lockf(int fildes, int function, off_t size)
+{
+ struct flock buf;
+
+ switch (function) {
+ case F_LOCK:
+ buf.l_type = F_WRLCK;
+ break;
+ case F_ULOCK:
+ buf.l_type = F_UNLCK;
+ break;
+ default:
+ return -1;
+ }
+ buf.l_whence = 0;
+ buf.l_start = 0;
+ buf.l_len = size;
+
+ return fcntl(fildes, F_SETLK, &buf);
+}
+
+#endif
Propchange: commons/proper/daemon/trunk/src/native/unix/native/locks.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/trunk/src/native/unix/native/locks.h
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/locks.h?rev=909069&view=auto
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/locks.h (added)
+++ commons/proper/daemon/trunk/src/native/unix/native/locks.h Thu Feb 11
16:43:36 2010
@@ -0,0 +1,39 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id$ */
+#ifndef __JSVC_LOCKS_H__
+#define __JSVC_LOCKS_H__
+
+/*
+ * as Cygwin does not support locks, jsvc use NT API to emulate them.
+ */
+#ifdef OS_CYGWIN
+
+#define F_ULOCK 0 /* Unlock a previously locked region */
+#define F_LOCK 1 /* Lock a region for exclusive use */
+
+/*
+ * allow a file to be locked
+ * @param fildes an open file descriptor
+ * @param function a control value that specifies the action to be taken
+ * @param size number of bytes to lock
+ * @return Zero on success, a value less than 0 if an error was encountered
+ */
+int lockf(int fildes, int function, off_t size);
+
+#endif
+#endif /* __JSVC_LOCKS_H__ */
+
Propchange: commons/proper/daemon/trunk/src/native/unix/native/locks.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/proper/daemon/trunk/src/native/unix/native/signals.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/signals.c?rev=909069&r1=909068&r2=909069&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/signals.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/signals.c Thu Feb 11
16:43:36 2010
@@ -17,14 +17,14 @@
/* @version $Id$ */
/*
- * as Windows does not support signal, jsvc use event to emulate them.
+ * as Windows does not support signal, jsvc uses events to emulate them.
* The supported signal is SIGTERM.
* The kills.c contains the kill logic.
*/
#ifdef OS_CYGWIN
#include <windows.h>
#include <stdio.h>
-static void (*HandleTerm)()=NULL; /* address of the handler routine. */
+static void (*HandleTerm)(void)=NULL; /* address of the handler routine. */
/*
* Event handling routine
@@ -51,7 +51,7 @@
* set a routine handler for the signal
* note that it cannot be used to change the signal handler
*/
-int SetTerm(void (*func)())
+int SetTerm(void (*func)(void))
{
char Name[256];
HANDLE hevint, hthread;
@@ -81,7 +81,7 @@
/* It works also with NULL instead &sa!! */
hevint = CreateEvent(&sa,FALSE, FALSE,Name);
- HandleTerm = (int (*)()) func;
+ HandleTerm = func;
if (hevint == NULL) return(-1); /* failed */