Skip to content

Commit

Permalink
fix a couple different cores.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Wells committed Nov 25, 2013
1 parent c8da2a5 commit 5da41cd
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion HttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool HttpServer::getDoc ( char *url ,
long defPort = 80;
// check for a secured site
TcpServer *tcp = &m_tcp;
if ( strncasecmp(url, "https://", 8) == 0 ) {
if ( url && strncasecmp(url, "https://", 8) == 0 ) {
if (!m_ssltcp.m_ready) {
// TODO: set an error here
log("https: Trying to get HTTPS site when SSL "
Expand Down
4 changes: 4 additions & 0 deletions Msg3a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ void Msg3a::constructor ( ) {
m_finalBuf = NULL;
m_docsToGet = 0;
m_numDocIds = 0;

// need to call all safebuf constructors now to set m_label
m_rbuf2.constructor();

// NULLify all the reply buffer ptrs
for ( long j = 0; j < MAX_INDEXDB_SPLIT; j++ )
m_reply[j] = NULL;
Expand Down
11 changes: 7 additions & 4 deletions Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2265,14 +2265,17 @@ void Process::checkFanSwitch ( ) {

if ( m_desiredFanState )
// this turns it on
urlBuf.safePrintf("http://10.5.0.10/outlet.cgi?outlet=1&"
if ( !urlBuf.safePrintf("http://10.5.0.10/outlet.cgi?outlet=1&"
"command=1&time=%li",
getTimeGlobal());
getTimeGlobal()) )
return;
else
// this turns it off
urlBuf.safePrintf("http://10.5.0.10/outlet.cgi?outlet=1&"
if ( !urlBuf.safePrintf("http://10.5.0.10/outlet.cgi?outlet=1&"
"command=0&time=%li",
getTimeGlobal());
getTimeGlobal()) )
return;

// . make a cookie with the login info
// . on chrome open the console and click "Network" tab
// to view the http network requests and replies
Expand Down
8 changes: 8 additions & 0 deletions SafeBuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ SafeBuf::SafeBuf(long initSize, char *label ) {
m_encoding = csUTF8;
}

void SafeBuf::constructor ( ) {
m_capacity = 0;
m_length = 0;
m_buf = NULL;
m_usingStack = false;
m_encoding = csUTF8;
m_label = NULL;
}

SafeBuf::SafeBuf() {
m_capacity = 0;
Expand Down
3 changes: 3 additions & 0 deletions SafeBuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ struct SafeBuf {
//*TRUCTORS
SafeBuf();
SafeBuf(long initSize, char *label = NULL);

void constructor();

//be careful with passing in a stackBuf! it could go out
//of scope independently of the safebuf.
SafeBuf(char* stackBuf, long cap);
Expand Down
27 changes: 26 additions & 1 deletion TcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,32 @@ long TcpServer::connectSocket ( TcpSocket *s ) {
void TcpServer::destroySocket ( TcpSocket *s ) {
if ( ! s ) return ;
// sanity check
if ( s->m_udpSlot ) { char *xx=NULL;*xx = 0; }
if ( s->m_udpSlot ) {
log("tcp: sending back error on udp slot err=%s",
mstrerror(g_errno));
//char *sendBuf = "Error. destroying sock.";
//long sendBufUsed = gbstrlen(sendBuf);
long timeout = 30*1000;
// sen back the error i guess
g_udpServer.sendReply_ass ( NULL,//sendBuf ,
0,//sendBufUsed ,
NULL,//sendBuf ,
0,//sendBufSize ,
s->m_udpSlot ,
timeout , // timeout?
NULL,//state ,
NULL );// callback
// we now free the read buffer here since PageDirectory.cpp
// might have reallocated it.
if ( s->m_readBuf )
mfree (s->m_readBuf, s->m_readBufSize,"TcpUdp");
// free it! we allocated in HttpServer.cpp handleRequestfd()
mfree ( s , sizeof(TcpSocket) , "tcpudp" );
// assume did not block
return;
//char *xx=NULL;*xx = 0; }
}

// . you cannot destroy socket's who have called a handler and the
// handler is still in progress, because when he's got a reply ready
// he expects this TcpSocket to still be there
Expand Down

0 comments on commit 5da41cd

Please sign in to comment.