Skip to content

Commit

Permalink
Fixed 64bit linux compilation issues
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Raiber <martin@urbackup.org>
  • Loading branch information
uroni committed Jul 3, 2011
1 parent 1d22c52 commit b8ccab5
Show file tree
Hide file tree
Showing 10 changed files with 1,372 additions and 1,339 deletions.
9 changes: 8 additions & 1 deletion AcceptThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void OutputCallback::operator() (const void* buf, size_t count)
Server->Log("Send failed in OutputCallback");
}

CAcceptThread::CAcceptThread( unsigned int nWorkerThreadsPerMaster, unsigned short int uPort )
CAcceptThread::CAcceptThread( unsigned int nWorkerThreadsPerMaster, unsigned short int uPort ) : error(false)
{
WorkerThreadsPerMaster=nWorkerThreadsPerMaster;

Expand All @@ -57,6 +57,7 @@ CAcceptThread::CAcceptThread( unsigned int nWorkerThreadsPerMaster, unsigned sho
if(s<1)
{
Server->Log("Creating SOCKET failed",LL_ERROR);
error=true;
return;
}
Server->Log("done.",LL_INFO);
Expand All @@ -72,6 +73,7 @@ CAcceptThread::CAcceptThread( unsigned int nWorkerThreadsPerMaster, unsigned sho
if(rc==SOCKET_ERROR)
{
Server->Log("Failed binding SOCKET to Port "+nconvert(uPort),LL_ERROR);
error=true;
return;
}

Expand Down Expand Up @@ -179,3 +181,8 @@ void CAcceptThread::AddToSelectThread(CClient *client)

Server->createThread(nt);
}

bool CAcceptThread::has_error(void)
{
return error;
}
3 changes: 3 additions & 0 deletions AcceptThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class CAcceptThread
~CAcceptThread();

void operator()(bool single=false);

bool has_error(void);

private:
void AddToSelectThread(CClient *client);
Expand All @@ -22,6 +24,7 @@ class CAcceptThread

SOCKET s;
unsigned int WorkerThreadsPerMaster;
bool error;
};

class OutputCallback : public FCGIProtocolDriver::OutputCallback
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AM_LDFLAGS = $(PTHREAD_LIBS) -ldl
SUBDIRS=. pychart downloadplugin fsimageplugin httpserver urbackup
install-exec-local: $(srcdir)/defaults $(srcdir)/init.d
$(INSTALL) -D $(srcdir)/init.d $(sysconfdir)/init.d/urbackup_srv
$(INSTALL) -D $(srcdir)/defaults $(DESTDIR)$(sysconfdir)/default/urbackup_srv
if ! test -e $(sysconfdir)/default/urbackup_srv; then $(INSTALL) -D $(srcdir)/defaults $(sysconfdir)/default/urbackup_srv; fi

mkdir -p $(DESTDIR)$(localstatedir)/urbackup
chown urbackup:urbackup $(DESTDIR)$(localstatedir)/urbackup
Expand Down
3 changes: 1 addition & 2 deletions defaults
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ LOGFILE="urbackup.log"
LOGLEVEL="warn"

#Tmp file directory - be carefull this can get very large
DAEMON_TMPDIR="/tmp"

DAEMON_TMPDIR="/tmp"
1 change: 1 addition & 0 deletions httpserver/HTTPFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ std::string CHTTPFile::getContentType(void)

void CHTTPFile::operator ()(void)
{
Server->Log("Sending file \""+filename+"\"", LL_DEBUG);
IFile *fp=Server->openFile(filename);

if( fp==NULL )
Expand Down
13 changes: 3 additions & 10 deletions init.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="UrBackup server deamon" # Introduce a short description here
NAME="urbackup_srv" # Introduce the short server's name here
DAEMON=/usr/bin/start_urbackup_server # Introduce the server's location here
if ! test -x $DAEMON
then
DAEMON=/usr/local/bin/start_urbackup_server
fi
DAEMON_REAL=/usr/bin/urbackup_srv
if ! test -x $DAEMON_REAL
then
DAEMON_REAL=/usr/local/bin/urbackup_srv
fi
PREFIX="/usr/local"
DAEMON=$PREFIX/bin/start_urbackup_server # Introduce the server's location here
DAEMON_REAL=$PREFIX/bin/urbackup_srv
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON_TMPDIR=/tmp
Expand Down
26 changes: 26 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ int my_init_fcn_t(int argc, char *argv[])
std::string workingdir;
bool daemon=false;
std::string daemon_user;
std::string pidfile;

for(int i=1;i<argc;++i)
{
Expand Down Expand Up @@ -188,11 +189,18 @@ int my_init_fcn_t(int argc, char *argv[])
else if (carg=="--loglevel" || carg=="-ll" )
{
loglevel=strlower(narg);
++i;
}
else if (carg=="--logfile" || carg=="-lf" )
{
logfile=narg;
++i;
}
else if( carg=="--pidfile" )
{
pidfile=narg;
++i;
}
else
{
if( carg.size()>1 && carg[0]=='-' )
Expand Down Expand Up @@ -270,6 +278,19 @@ int my_init_fcn_t(int argc, char *argv[])
exit(0);

chdir(Server->ConvertToUTF8(Server->getServerWorkingDir()).c_str());

if(pidfile.empty())
{
pidfile="/var/run/urbackup_srv.pid";
}

std::fstream pf;
pf.open(pidfile.c_str(), std::ios::out|std::ios::binary);
if(pf.is_open())
{
pf << getpid();
pf.close();
}
}
#endif

Expand Down Expand Up @@ -357,6 +378,11 @@ int my_init_fcn_t(int argc, char *argv[])
{
init_mutex_selthread();
c_at=new CAcceptThread(workers, port);
if(c_at->has_error())
{
Server->Log("Error while starting listening to ports. Stopping server.", LL_ERROR);
run=false;
}
#ifndef AS_SERVICE
while(run==true)
{
Expand Down
28 changes: 13 additions & 15 deletions start_urbackup_server
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/sh

NAME="urbackup_srv"
DAEMON=/usr/bin/urbackup_srv
PREFIX=/usr
DAEMON=$PREFIX/bin/urbackup_srv
if ! test -x $DAEMON
then
DAEMON=/usr/local/bin/urbackup_srv
PREFIX=/usr/local
fi

DAEMON_DIR="/var"
Expand All @@ -13,12 +14,7 @@ then
DAEMON_DIR="/usr/local/var"
fi

DAEMON_LIBS="/usr/lib"
if ! test -e $DAEMON_LIBS/liburbackupserver.so
then
DAEMON_LIBS="/usr/local/lib"
fi

DAEMON_LIBS="$PREFIX/lib"
PLUGIN_PYCHART="--plugin $DAEMON_LIBS/liburbackupserver_pychart.so"
if ! test -e $DAEMON_LIBS/liburbackupserver_pychart.so
then
Expand All @@ -32,11 +28,12 @@ print_help()
{
echo "UrBackup server wrapper script. Starts UrBackup Server."
echo "Parameters:"
echo "--fastcgi_port [port] Specifies the port where UrBackup server will listen for FastCGI connections. Default: 55413"
echo "--http_port [port] Specifies the port where UrBackup server will listen for HTTP connections. Default: 55414"
echo "--logfile [file] Specifies the log file name. Default: urbackup.log"
echo "--loglevel [debug|info|warn|error] Specifies the log level. Possible values: debug, info, warn, error. Default: warn"
echo "--fastcgi_port {port} Specifies the port where UrBackup server will listen for FastCGI connections. Default: 55413"
echo "--http_port {port} Specifies the port where UrBackup server will listen for HTTP connections. Default: 55414"
echo "--logfile {file} Specifies the log file name. Default: urbackup.log"
echo "--loglevel {debug|info|warn|error} Specifies the log level. Possible values: debug, info, warn, error. Default: warn"
echo "--no_deamon Do not start as a daemon"
echo "--pidfile {file} Save pid of daemon in file"
echo ""
echo "Have a nice day!"
exit 0
Expand All @@ -57,14 +54,16 @@ if `getopt -T > /dev/null 2>&1`; [ $? = 4 ]; then
HTTP_PORT=55414
LOGFILE="urbackup.log"
LOGLEVEL="warn"
TEMP=`getopt -o f:h:l:v -n start_urbackup_server --long version,no_daemon,help,fastcgi_port:,http_port:,logfile:,loglevel: -- "$@"`
PIDFILE="/var/run/urbackup_srv.pid"
TEMP=`getopt -o f:h:l:v -n start_urbackup_server --long version,no_daemon,help,fastcgi_port:,http_port:,logfile:,loglevel:,pidfile: -- "$@"`
eval set -- "$TEMP"
while true ; do
case "$1" in
-f|--fastcgi_port) FASTCGI_PORT="$2"; shift 2 ;;
-h|--http_port) HTTP_PORT="$2"; shift 2 ;;
-l|--logfile) LOGFILE="$2"; shift 2 ;;
-v|--loglevel) LOGLEVEL="$2"; shift 2 ;;
--pidfile) PIDFILE="$2"; shift 2 ;;
--no_daemon) S_DAEMON=""; shift ;;
--help) print_help ;;
--version) print_version ;;
Expand All @@ -73,7 +72,7 @@ if `getopt -T > /dev/null 2>&1`; [ $? = 4 ]; then
esac
done

DAEMON_ARGS="--port $FASTCGI_PORT --logfile /var/log/$LOGFILE --loglevel $LOGLEVEL --http_port $HTTP_PORT"
DAEMON_ARGS="--port $FASTCGI_PORT --logfile /var/log/$LOGFILE --loglevel $LOGLEVEL --http_port $HTTP_PORT --pidfile $PIDFILE"
else
DAEMON_ARGS="$*"
fi
Expand All @@ -86,7 +85,6 @@ then
fi

ulimit -n 10000 > /dev/null 2>&1
ulimit -c unlimited

export MPLCONFIGDIR=$DAEMON_DIR/urbackup

Expand Down
1 change: 1 addition & 0 deletions urbackup/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ install-data-local: $(srcdir)/backup_server.db $(srcdir)/status.htm $(srcdir)/ww
$(INSTALL_DATA) $(INSTALL_OPTS) -D $(srcdir)/status.htm $(DESTDIR)$(localstatedir)/urbackup/status.htm
$(INSTALL_DATA) $(INSTALL_OPTS) $(srcdir)/google_chart.js $(DESTDIR)$(localstatedir)/urbackup/
$(INSTALL_DATA) $(INSTALL_OPTS) -d $(DESTDIR)$(localstatedir)/urbackup/www
chmod u+x $(DESTDIR)$(localstatedir)/urbackup/www
$(INSTALL_DATA) $(INSTALL_OPTS) $(srcdir)/www/*.js $(DESTDIR)$(localstatedir)/urbackup/www/
$(INSTALL_DATA) $(INSTALL_OPTS) $(srcdir)/www/*.htm $(DESTDIR)$(localstatedir)/urbackup/www/
$(INSTALL_DATA) $(INSTALL_OPTS) $(srcdir)/www/*.css $(DESTDIR)$(localstatedir)/urbackup/www/
Expand Down
Loading

0 comments on commit b8ccab5

Please sign in to comment.