diff options
author | Andreas Huber <andih@google.com> | 2010-09-15 17:53:17 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-09-15 17:53:17 -0700 |
commit | ac5f724d00c8ac2040f01485873b6373f8994354 (patch) | |
tree | 3735c4aa7f454f1bc7d590abaa3b79f464d260ad /media/libstagefright/rtsp/ARTSPConnection.cpp | |
parent | 616715ab614ce25ea395a8e9a553a82637f1021d (diff) | |
parent | 09a38311206a19b79ca302b9cad926608e938fd4 (diff) | |
download | frameworks_av-ac5f724d00c8ac2040f01485873b6373f8994354.zip frameworks_av-ac5f724d00c8ac2040f01485873b6373f8994354.tar.gz frameworks_av-ac5f724d00c8ac2040f01485873b6373f8994354.tar.bz2 |
am 7ff94577: am 9909b948: Merge "Various fixes to improve resilience of the rtsp stack against spurious errors instead of asserting." into gingerbread
Merge commit '7ff945775210c60e6f113fb00903449cbb05c68a'
* commit '7ff945775210c60e6f113fb00903449cbb05c68a':
Various fixes to improve resilience of the rtsp stack against spurious errors instead of asserting.
Diffstat (limited to 'media/libstagefright/rtsp/ARTSPConnection.cpp')
-rw-r--r-- | media/libstagefright/rtsp/ARTSPConnection.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp index fd6aa62..dcff64c 100644 --- a/media/libstagefright/rtsp/ARTSPConnection.cpp +++ b/media/libstagefright/rtsp/ARTSPConnection.cpp @@ -175,19 +175,38 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) { mState = CONNECTING; - mSocket = socket(AF_INET, SOCK_STREAM, 0); - - MakeSocketBlocking(mSocket, false); - AString url; CHECK(msg->findString("url", &url)); + sp<AMessage> reply; + CHECK(msg->findMessage("reply", &reply)); + AString host, path; unsigned port; - CHECK(ParseURL(url.c_str(), &host, &port, &path)); + if (!ParseURL(url.c_str(), &host, &port, &path)) { + LOG(ERROR) << "Malformed rtsp url " << url; + + reply->setInt32("result", ERROR_MALFORMED); + reply->post(); + + mState = DISCONNECTED; + return; + } struct hostent *ent = gethostbyname(host.c_str()); - CHECK(ent != NULL); + if (ent == NULL) { + LOG(ERROR) << "Unknown host " << host; + + reply->setInt32("result", -ENOENT); + reply->post(); + + mState = DISCONNECTED; + return; + } + + mSocket = socket(AF_INET, SOCK_STREAM, 0); + + MakeSocketBlocking(mSocket, false); struct sockaddr_in remote; memset(remote.sin_zero, 0, sizeof(remote.sin_zero)); @@ -198,9 +217,6 @@ void ARTSPConnection::onConnect(const sp<AMessage> &msg) { int err = ::connect( mSocket, (const struct sockaddr *)&remote, sizeof(remote)); - sp<AMessage> reply; - CHECK(msg->findMessage("reply", &reply)); - reply->setInt32("server-ip", ntohl(remote.sin_addr.s_addr)); if (err < 0) { @@ -337,13 +353,20 @@ void ARTSPConnection::onSendRequest(const sp<AMessage> &msg) { if (n == 0) { // Server closed the connection. - TRESPASS(); + LOG(ERROR) << "Server unexpectedly closed the connection."; + + reply->setInt32("result", ERROR_IO); + reply->post(); + return; } else if (n < 0) { if (errno == EINTR) { continue; } - TRESPASS(); + LOG(ERROR) << "Error sending rtsp request."; + reply->setInt32("result", -errno); + reply->post(); + return; } numBytesSent += (size_t)n; @@ -415,13 +438,15 @@ status_t ARTSPConnection::receive(void *data, size_t size) { ssize_t n = recv(mSocket, (uint8_t *)data + offset, size - offset, 0); if (n == 0) { // Server closed the connection. + LOG(ERROR) << "Server unexpectedly closed the connection."; return ERROR_IO; } else if (n < 0) { if (errno == EINTR) { continue; } - TRESPASS(); + LOG(ERROR) << "Error reading rtsp response."; + return -errno; } offset += (size_t)n; |