Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
http: use UInt_t instead of void* for websocket ID
  • Loading branch information
linev committed Apr 10, 2017
commit fbb4998ee9eac060ce28e7526360c48cb1cea0a6
6 changes: 3 additions & 3 deletions net/http/inc/THttpCallArg.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class THttpCallArg : public TObject {
Long_t fPostDataLength; ///<! length of binary data

TNamed *fWSHandle; ///<! web-socket handle, derived from TNamed class
void * fWSId; ///<! websocket identifier, used in web-socket related operations
UInt_t fWSId; ///<! websocket identifier, used in web-socket related operations

std::condition_variable fCond; ///<! condition used to wait for processing

Expand Down Expand Up @@ -89,10 +89,10 @@ class THttpCallArg : public TObject {
TNamed *TakeWSHandle();

/** set web-socket id */
void SetWSId(void *id) { fWSId = id; }
void SetWSId(UInt_t id) { fWSId = id; }

/** get web-socket id */
void *GetWSId() const { return fWSId; }
UInt_t GetWSId() const { return fWSId; }

/** set full set of request header */
void SetRequestHeader(const char *h) { fRequestHeader = h ? h : ""; }
Expand Down
2 changes: 1 addition & 1 deletion net/http/inc/THttpEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class THttpWSEngine : public TNamed {
public:
virtual ~THttpWSEngine();

virtual void *GetId() const = 0;
virtual UInt_t GetId() const = 0;

virtual void ClearHandle() = 0;

Expand Down
10 changes: 5 additions & 5 deletions net/http/src/TCivetweb.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TCivetwebWSEngine : public THttpWSEngine {

virtual ~TCivetwebWSEngine() {}

virtual void *GetId() const { return (void *)fWSconn; }
virtual UInt_t GetId() const { return TString::Hash((void *)fWSconn, sizeof(void *)); }

virtual void ClearHandle() { fWSconn = 0; }

Expand All @@ -64,7 +64,7 @@ int websocket_connect_handler(const struct mg_connection *conn, void *)
THttpCallArg arg;
arg.SetPathAndFileName(request_info->uri); // path and file name
arg.SetQuery(request_info->query_string); // query arguments
arg.SetWSId((void *)conn);
arg.SetWSId(TString::Hash((void *)conn, sizeof(void *)));
arg.SetMethod("WS_CONNECT");

Bool_t execres = serv->ExecuteHttp(&arg);
Expand All @@ -88,7 +88,7 @@ void websocket_ready_handler(struct mg_connection *conn, void *)
arg.SetQuery(request_info->query_string); // query arguments
arg.SetMethod("WS_READY");

arg.SetWSId((void *)conn);
arg.SetWSId(TString::Hash((void *)conn, sizeof(void *)));
arg.SetWSHandle(new TCivetwebWSEngine("websocket", "title", conn));

serv->ExecuteHttp(&arg);
Expand All @@ -108,7 +108,7 @@ int websocket_data_handler(struct mg_connection *conn, int, char *data, size_t l
THttpCallArg arg;
arg.SetPathAndFileName(request_info->uri); // path and file name
arg.SetQuery(request_info->query_string); // query arguments
arg.SetWSId((void *)conn);
arg.SetWSId(TString::Hash((void *)conn, sizeof(void *)));
arg.SetMethod("WS_DATA");

void *buf = malloc(len + 1); // one byte more for null-termination
Expand All @@ -134,7 +134,7 @@ void websocket_close_handler(const struct mg_connection *conn, void *)
THttpCallArg arg;
arg.SetPathAndFileName(request_info->uri); // path and file name
arg.SetQuery(request_info->query_string); // query arguments
arg.SetWSId((void *)conn);
arg.SetWSId(TString::Hash((void *)conn, sizeof(void *)));
arg.SetMethod("WS_CLOSE");

serv->ExecuteHttp(&arg);
Expand Down