You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 07:35:49 UTC
svn commit: r1131808 - in /incubator/mesos/trunk/src: master_main.cpp
master_webui.cpp master_webui.hpp
Author: benh
Date: Sun Jun 5 05:35:49 2011
New Revision: 1131808
URL: http://svn.apache.org/viewvc?rev=1131808&view=rev
Log:
Bug fixes. Fixed wehre I was passing pointer to local variable to pthread_create().
Modified:
incubator/mesos/trunk/src/master_main.cpp
incubator/mesos/trunk/src/master_webui.cpp
incubator/mesos/trunk/src/master_webui.hpp
Modified: incubator/mesos/trunk/src/master_main.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master_main.cpp?rev=1131808&r1=1131807&r2=1131808&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master_main.cpp (original)
+++ incubator/mesos/trunk/src/master_main.cpp Sun Jun 5 05:35:49 2011
@@ -47,7 +47,7 @@ int main (int argc, char **argv)
int opt;
int index;
- string webuiport = "";
+ string webuiPortStr = "8080";
while ((opt = getopt_long(argc, argv, "u:a:p:w:q", options, &index)) != -1) {
switch (opt) {
case 'u':
@@ -60,7 +60,7 @@ int main (int argc, char **argv)
setenv("LIBPROCESS_PORT", optarg, 1);
break;
case 'w':
- webuiport = optarg;
+ webuiPortStr = optarg;
break;
case 'q':
quiet = true;
@@ -93,7 +93,13 @@ int main (int argc, char **argv)
#ifdef NEXUS_WEBUI
if (chdir(dirname(argv[0])) != 0)
fatalerror("could not change into %s for running webui", dirname(argv[0]));
- startMasterWebUI(pid, webuiport);
+ long webuiPort;
+ std::istringstream webuiPortStream(webuiPortStr);
+
+ if (webuiPortStream>>webuiPort)
+ startMasterWebUI(pid, webuiPort);
+ else
+ fatalerror("Passed invalid string for webui port number.");
#endif
Process::wait(pid);
Modified: incubator/mesos/trunk/src/master_webui.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master_webui.cpp?rev=1131808&r1=1131807&r2=1131808&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master_webui.cpp (original)
+++ incubator/mesos/trunk/src/master_webui.cpp Sun Jun 5 05:35:49 2011
@@ -19,16 +19,17 @@ PID master;
namespace nexus { namespace internal { namespace master {
-void *runMasterWebUI(void * webuiport)
+void *runMasterWebUI(void* webuiPort)
{
- string portstring = *(string*)webuiport;
- char shortstr[50];
- portstring.copy(shortstr,20);
+ std::ostringstream oss;
+ oss << (const long)webuiPort;
+ char webuiPortStr[50];
+ oss.str().copy(webuiPortStr,20);
LOG(INFO) << "Web UI thread started";
Py_Initialize();
char** nargv = (char**)malloc(sizeof(char*)*2);
nargv[0] = "webui/master/webui.py";
- nargv[1] = shortstr;
+ nargv[1] = webuiPortStr;
PySys_SetArgv(2,nargv);
PyRun_SimpleString("import sys\n"
"sys.path.append('webui/master/swig')\n"
@@ -43,12 +44,12 @@ void *runMasterWebUI(void * webuiport)
}
-void startMasterWebUI(PID master, string webuiport)
+void startMasterWebUI(const PID &master, const long &webuiPortNum)
{
LOG(INFO) << "Starting master web UI";
::master = master;
pthread_t thread;
- pthread_create(&thread, 0, runMasterWebUI, &webuiport);
+ pthread_create(&thread, 0, runMasterWebUI, (void*)webuiPortNum);
}
Modified: incubator/mesos/trunk/src/master_webui.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master_webui.hpp?rev=1131808&r1=1131807&r2=1131808&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master_webui.hpp (original)
+++ incubator/mesos/trunk/src/master_webui.hpp Sun Jun 5 05:35:49 2011
@@ -10,7 +10,7 @@
namespace nexus { namespace internal { namespace master {
-void startMasterWebUI(PID master, string webuiport);
+void startMasterWebUI(const PID &master, const long &webuiport);
}}} /* namespace */