Skip to content

Commit

Permalink
fix linux compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Feb 18, 2020
1 parent f221f96 commit 87606c8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 137 deletions.
2 changes: 1 addition & 1 deletion examples/CustomDemo/CustomServer/CustomServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static TC_NetWorkBuffer::PACKET_TYPE parse(TC_NetWorkBuffer &in, vector<char> &o

iHeaderLen = ntohl(iHeaderLen);

if (iHeaderLen > 100000 || iHeaderLen < sizeof(unsigned int))
if (iHeaderLen > 100000 || iHeaderLen < (int)sizeof(unsigned int))
{
throw TarsDecodeException("packet length too long or too short,len:" + TC_Common::tostr(iHeaderLen));
}
Expand Down
136 changes: 1 addition & 135 deletions servant/libservant/AppProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@

#if TARS_HTTP2
#include "util/tc_http2.h"
//#include "nghttp2/nghttp2.h"
#endif

namespace tars
{

// //TAFServer的协议解析器
// TC_NetWorkBuffer::PACKET_TYPE AppProtocol::parseAdmin(TC_NetWorkBuffer &in, shared_ptr<TC_NetWorkBuffer::Buffer> &out)
// {
// return parse(in, out->getBuffer());
// }

vector<char> ProxyProtocol::tarsRequest(RequestPacket& request, Transceiver *)
{
TarsOutputStream<BufferWriterVector> os;
Expand Down Expand Up @@ -124,48 +117,7 @@ TC_NetWorkBuffer::PACKET_TYPE ProxyProtocol::http1Response(TC_NetWorkBuffer &in,
}

#if TARS_HTTP2
//
//#define MAKE_NV(NAME, VALUE, VALUELEN) \
// { \
// (uint8_t *)NAME, (uint8_t *)VALUE, sizeof(NAME) - 1, VALUELEN, \
// NGHTTP2_NV_FLAG_NONE \
// }
//
//#define MAKE_NV2(NAME, VALUE) \
// { \
// (uint8_t *)NAME, (uint8_t *)VALUE, sizeof(NAME) - 1, sizeof(VALUE) - 1, \
// NGHTTP2_NV_FLAG_NONE \
// }
//
//#define MAKE_STRING_NV(NAME, VALUE) {(uint8_t*)(NAME.data()), (uint8_t*)(VALUE.data()), NAME.size(), VALUE.size(), NGHTTP2_NV_FLAG_NONE};
//
//// nghttp2读取请求包体,准备发送
//static ssize_t reqbody_read_callback(nghttp2_session *session, int32_t stream_id,
// uint8_t *buf, size_t length,
// uint32_t *data_flags,
// nghttp2_data_source *source,
// void *user_data)
//{
// std::vector<char>* body = (std::vector<char>* )source->ptr;
// // cout << "reqbody_read_callback:" << body->size() << endl;
//
// if (body->empty())
// {
// *data_flags |= NGHTTP2_DATA_FLAG_EOF;
// return 0;
// }
//
// ssize_t len = length > body->size() ? body->size() : length;
// memcpy(buf, body->data(), len);
//
// vector<char>::iterator end = body->begin();
// std::advance(end, len);
// body->erase(body->begin(), end);
//
// return len;
//}

//std::mutex m;

// ENCODE function, called by network thread
vector<char> ProxyProtocol::http2Request(RequestPacket& request, Transceiver *trans)
{
Expand All @@ -190,60 +142,6 @@ vector<char> ProxyProtocol::http2Request(RequestPacket& request, Transceiver *tr
session->swap(out);

return out;
//
// std::vector<nghttp2_nv> nva;
//
// const std::string method(":method");
// nghttp2_nv nv1 = MAKE_STRING_NV(method, request.sFuncName);
// if (!request.sFuncName.empty())
// nva.push_back(nv1);
//
// const std::string path(":path");
// nghttp2_nv nv2 = MAKE_STRING_NV(path, request.sServantName);
// if (!request.sServantName.empty())
// nva.push_back(nv2);
//
// for (std::map<std::string, std::string>::const_iterator it(request.context.begin()); it != request.context.end(); ++ it)
// {
// nghttp2_nv nv = MAKE_STRING_NV(it->first, it->second);
// nva.push_back(nv);
// }
//
// nghttp2_data_provider* pData = NULL;
// nghttp2_data_provider data;
// if (!request.sBuffer.empty())
// {
// pData = &data;
// data.source.ptr = (void*)&request.sBuffer;
// data.read_callback = reqbody_read_callback;
// }
//
// int32_t sid = nghttp2_submit_request(session->session(),
// NULL,
// nva.data(),
// nva.size(),
// pData,
// NULL);
// if (sid < 0)
// {
// TLOGERROR("[TARS]http2Request::Fatal error: nghttp2_submit_request return: " << sid << endl);
// return vector<char>();
// }
//
// request.iRequestId = sid;
//
//// cout << "http2Request id:" << request.iRequestId << endl;
//
// int rv = nghttp2_session_send(session->session());
// if (rv != 0) {
// TLOGERROR("[TARS]http2Request::Fatal error: nghttp2_session_send return: " << nghttp2_strerror(rv) << ", " << std::this_thread::get_id() << ", session:" << session << endl);
// return vector<char>();
// }
//
// vector<char> out;
// session->swap(out);
//
// return out;
}

TC_NetWorkBuffer::PACKET_TYPE ProxyProtocol::http2Response(TC_NetWorkBuffer &in, ResponsePacket& rsp)
Expand All @@ -269,38 +167,6 @@ TC_NetWorkBuffer::PACKET_TYPE ProxyProtocol::http2Response(TC_NetWorkBuffer &in,
}

return flag;
//
// auto it = session->doneResponses().begin();
// if(!in.empty())
// {
// //merge to one buffer
// in.mergeBuffers();
//
// pair<const char*, size_t> buffer = in.getBufferPointer();
//
// int readlen = nghttp2_session_mem_recv(session->session(), (const uint8_t*)buffer.first, buffer.second);
// if (readlen < 0)
// {
// TLOGERROR("[TARS]http2Response::Fatal error: nghttp2_session_mem_recv error:" << nghttp2_strerror((int)readlen) << endl);
// return TC_NetWorkBuffer::PACKET_ERR;
// }
//
// in.moveHeader(readlen);
// }
//
// if(session->doneResponses().empty())
// {
// return TC_NetWorkBuffer::PACKET_LESS;
// }
//
// it = session->doneResponses().begin();
// rsp.iRequestId = it->first;
// it->second->getHeaders(rsp.status);
// rsp.sBuffer.assign(it->second->getContent().begin(), it->second->getContent().end());
//
// session->doneResponses().erase(it);

// return TC_NetWorkBuffer::PACKET_FULL;
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion servant/protocol
1 change: 1 addition & 0 deletions util/include/util/tc_gzip.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <vector>
#include <string.h>
#include <cassert>
#include <memory>

using namespace std;

Expand Down

0 comments on commit 87606c8

Please sign in to comment.