mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
parent
b5dd502103
commit
6118ca382a
4 changed files with 41 additions and 4 deletions
|
@ -178,6 +178,13 @@ srs_error_t SrsConnection::cycle()
|
||||||
srs_trace("client finished.");
|
srs_trace("client finished.");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// It maybe success with message.
|
||||||
|
if (srs_error_code(err) == ERROR_SUCCESS) {
|
||||||
|
srs_trace("client finished%s.", srs_error_summary(err).c_str());
|
||||||
|
srs_freep(err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
// client close peer.
|
// client close peer.
|
||||||
// TODO: FIXME: Only reset the error when client closed it.
|
// TODO: FIXME: Only reset the error when client closed it.
|
||||||
|
|
|
@ -1431,6 +1431,11 @@ srs_error_t SrsHttpApi::do_cycle()
|
||||||
|
|
||||||
// get a http message
|
// get a http message
|
||||||
if ((err = parser->parse_message(skt, &req)) != srs_success) {
|
if ((err = parser->parse_message(skt, &req)) != srs_success) {
|
||||||
|
// For HTTP timeout, we think it's ok.
|
||||||
|
if (srs_error_code(err) == ERROR_SOCKET_TIMEOUT) {
|
||||||
|
srs_freep(err);
|
||||||
|
return srs_error_wrap(srs_success, "http api timeout");
|
||||||
|
}
|
||||||
return srs_error_wrap(err, "parse message");
|
return srs_error_wrap(err, "parse message");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,14 +69,14 @@ std::string SrsCplxError::description() {
|
||||||
if (desc.empty()) {
|
if (desc.empty()) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << "code=" << code;
|
ss << "code=" << code;
|
||||||
|
|
||||||
SrsCplxError* next = this;
|
SrsCplxError* next = this;
|
||||||
while (next) {
|
while (next) {
|
||||||
ss << " : " << next->msg;
|
ss << " : " << next->msg;
|
||||||
next = next->wrapped;
|
next = next->wrapped;
|
||||||
}
|
}
|
||||||
ss << endl;
|
ss << endl;
|
||||||
|
|
||||||
next = this;
|
next = this;
|
||||||
while (next) {
|
while (next) {
|
||||||
ss << "thread [" << getpid() << "][" << next->cid << "]: "
|
ss << "thread [" << getpid() << "][" << next->cid << "]: "
|
||||||
|
@ -89,13 +89,29 @@ std::string SrsCplxError::description() {
|
||||||
ss << endl;
|
ss << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
desc = ss.str();
|
desc = ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SrsCplxError::summary() {
|
||||||
|
if (_summary.empty()) {
|
||||||
|
stringstream ss;
|
||||||
|
|
||||||
|
SrsCplxError* next = this;
|
||||||
|
while (next) {
|
||||||
|
ss << " : " << next->msg;
|
||||||
|
next = next->wrapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
_summary = ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _summary;
|
||||||
|
}
|
||||||
|
|
||||||
SrsCplxError* SrsCplxError::create(const char* func, const char* file, int line, int code, const char* fmt, ...) {
|
SrsCplxError* SrsCplxError::create(const char* func, const char* file, int line, int code, const char* fmt, ...) {
|
||||||
int rerrno = (int)errno;
|
int rerrno = (int)errno;
|
||||||
|
|
||||||
|
@ -178,6 +194,11 @@ string SrsCplxError::description(SrsCplxError* err)
|
||||||
return err? err->description() : "Success";
|
return err? err->description() : "Success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string SrsCplxError::summary(SrsCplxError* err)
|
||||||
|
{
|
||||||
|
return err? err->summary() : "Success";
|
||||||
|
}
|
||||||
|
|
||||||
int SrsCplxError::error_code(SrsCplxError* err)
|
int SrsCplxError::error_code(SrsCplxError* err)
|
||||||
{
|
{
|
||||||
return err? err->code : ERROR_SUCCESS;
|
return err? err->code : ERROR_SUCCESS;
|
||||||
|
|
|
@ -380,18 +380,21 @@ private:
|
||||||
int rerrno;
|
int rerrno;
|
||||||
|
|
||||||
std::string desc;
|
std::string desc;
|
||||||
|
std::string _summary;
|
||||||
private:
|
private:
|
||||||
SrsCplxError();
|
SrsCplxError();
|
||||||
public:
|
public:
|
||||||
virtual ~SrsCplxError();
|
virtual ~SrsCplxError();
|
||||||
private:
|
private:
|
||||||
virtual std::string description();
|
virtual std::string description();
|
||||||
|
virtual std::string summary();
|
||||||
public:
|
public:
|
||||||
static SrsCplxError* create(const char* func, const char* file, int line, int code, const char* fmt, ...);
|
static SrsCplxError* create(const char* func, const char* file, int line, int code, const char* fmt, ...);
|
||||||
static SrsCplxError* wrap(const char* func, const char* file, int line, SrsCplxError* err, const char* fmt, ...);
|
static SrsCplxError* wrap(const char* func, const char* file, int line, SrsCplxError* err, const char* fmt, ...);
|
||||||
static SrsCplxError* success();
|
static SrsCplxError* success();
|
||||||
static SrsCplxError* copy(SrsCplxError* from);
|
static SrsCplxError* copy(SrsCplxError* from);
|
||||||
static std::string description(SrsCplxError* err);
|
static std::string description(SrsCplxError* err);
|
||||||
|
static std::string summary(SrsCplxError* err);
|
||||||
static int error_code(SrsCplxError* err);
|
static int error_code(SrsCplxError* err);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -401,6 +404,7 @@ public:
|
||||||
#define srs_error_wrap(err, fmt, ...) SrsCplxError::wrap(__FUNCTION__, __FILE__, __LINE__, err, fmt, ##__VA_ARGS__)
|
#define srs_error_wrap(err, fmt, ...) SrsCplxError::wrap(__FUNCTION__, __FILE__, __LINE__, err, fmt, ##__VA_ARGS__)
|
||||||
#define srs_error_copy(err) SrsCplxError::copy(err)
|
#define srs_error_copy(err) SrsCplxError::copy(err)
|
||||||
#define srs_error_desc(err) SrsCplxError::description(err)
|
#define srs_error_desc(err) SrsCplxError::description(err)
|
||||||
|
#define srs_error_summary(err) SrsCplxError::summary(err)
|
||||||
#define srs_error_code(err) SrsCplxError::error_code(err)
|
#define srs_error_code(err) SrsCplxError::error_code(err)
|
||||||
#define srs_error_reset(err) srs_freep(err); err = srs_success
|
#define srs_error_reset(err) srs_freep(err); err = srs_success
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue