fix a bug in Socket::recv().
This commit is contained in:
parent
49ad0c5493
commit
f1d3e2c3b8
|
@ -11,22 +11,7 @@
|
|||
/* _query is a SPARQL query string */
|
||||
BasicQuery::BasicQuery(const string _query)
|
||||
{
|
||||
this->option_vs.clear();
|
||||
this->triple_vt.clear();
|
||||
this->var_str2id.clear();
|
||||
this->var_degree = NULL;
|
||||
this->is_literal_candidate_added = NULL;
|
||||
this->edge_id = NULL;
|
||||
this->edge_nei_id = NULL;
|
||||
this->edge_pre_id = NULL;
|
||||
this->edge_type = NULL;
|
||||
this->var_sig = NULL;
|
||||
this->edge_sig = NULL;
|
||||
this->encode_method = BasicQuery::NOT_JUST_SELECT;
|
||||
this->candidate_list = NULL;
|
||||
this->graph_var_num = 0;
|
||||
this->select_var_num = 0;
|
||||
this->var_name = 0;
|
||||
this->initial();
|
||||
}
|
||||
|
||||
BasicQuery::~BasicQuery()
|
||||
|
@ -410,6 +395,25 @@ const Triple& BasicQuery::getTriple(int _i_th_triple)
|
|||
}
|
||||
|
||||
/* private methods */
|
||||
void BasicQuery::null_initial()
|
||||
{
|
||||
this->option_vs.clear();
|
||||
this->triple_vt.clear();
|
||||
this->var_str2id.clear();
|
||||
this->var_degree = NULL;
|
||||
this->is_literal_candidate_added = NULL;
|
||||
this->edge_id = NULL;
|
||||
this->edge_nei_id = NULL;
|
||||
this->edge_pre_id = NULL;
|
||||
this->edge_type = NULL;
|
||||
this->var_sig = NULL;
|
||||
this->edge_sig = NULL;
|
||||
this->encode_method = BasicQuery::NOT_JUST_SELECT;
|
||||
this->candidate_list = NULL;
|
||||
this->graph_var_num = 0;
|
||||
this->select_var_num = 0;
|
||||
this->var_name = 0;
|
||||
}
|
||||
|
||||
void BasicQuery::initial()
|
||||
{
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
void findVarNotInSelect();
|
||||
void buildTuple2Freq();
|
||||
void initial();
|
||||
void null_initial();
|
||||
|
||||
public:
|
||||
static const char EDGE_IN = 'i';
|
||||
|
|
|
@ -178,22 +178,25 @@ int Socket::recv(std::string& _msg)const
|
|||
}
|
||||
|
||||
char* buf = new char[msg_len];
|
||||
recv_return = ::recv(this->sock, buf, msg_len, 0);
|
||||
|
||||
if (recv_return == -1)
|
||||
int recv_len = 0;
|
||||
do
|
||||
{
|
||||
std::cerr << "receive message context error, errno=" << errno << ".@Socket::recv" << std::endl;
|
||||
delete[] buf;
|
||||
int cur_len = ::recv(this->sock, buf + recv_len, msg_len - recv_len, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_msg = buf;
|
||||
delete[] buf;
|
||||
if (cur_len == -1)
|
||||
{
|
||||
std::cerr << "receive message context error, errno=" << errno << ".@Socket::recv" << std::endl;
|
||||
delete[] buf;
|
||||
|
||||
return recv_return;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
recv_len += cur_len;
|
||||
}while (recv_len < msg_len);
|
||||
|
||||
_msg = buf;
|
||||
delete[] buf;
|
||||
|
||||
return msg_len;
|
||||
}
|
||||
|
||||
bool Socket::connect(const std::string _hostname, const unsigned short _port)
|
||||
|
|
Loading…
Reference in New Issue