[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] [SCM] Gnash branch, master, updated. 7b1ae9f0b3846d953a0d
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] [SCM] Gnash branch, master, updated. 7b1ae9f0b3846d953a0d91ef4b02517f9917ebbf |
Date: |
Wed, 27 Oct 2010 11:29:49 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".
The branch, master has been updated
via 7b1ae9f0b3846d953a0d91ef4b02517f9917ebbf (commit)
via 9f22daa6b6509b420b798b885c885a1e9f83e00a (commit)
via 3d72440aa3f550b3d93aac6aa3eb84ec5d02cd3d (commit)
via afd2f99ccd0dde2a4e42948da4029459dd0fcc57 (commit)
via e5d16688f150dd64f6b279dac85ccd9545395279 (commit)
via f82b8f90c356e5d67044979e9f255572a0374288 (commit)
via 052597c426e091866827c12074e727a9781b81f2 (commit)
via 23bc396aabf94aead11b4f552b789e77a29eb1ef (commit)
via f85abb39021eeded3f92c066851e26496e19e25d (commit)
from 1d6558ab6b2bad9083b2aeae609c0f4b63171a30 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=7b1ae9f0b3846d953a0d91ef4b02517f9917ebbf
commit 7b1ae9f0b3846d953a0d91ef4b02517f9917ebbf
Merge: 9f22daa 1d6558a
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 13:29:38 2010 +0200
Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash
http://git.savannah.gnu.org/cgit//commit/?id=9f22daa6b6509b420b798b885c885a1e9f83e00a
commit 9f22daa6b6509b420b798b885c885a1e9f83e00a
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 13:07:25 2010 +0200
Don't report reply length.
diff --git a/libcore/asobj/NetConnection_as.cpp
b/libcore/asobj/NetConnection_as.cpp
index eb85223..afea87c 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -482,8 +482,10 @@ HTTPRemotingHandler::advance()
// in the adobe player) sends
// 0xffffffff. So we just ignore it
if (b + 4 > end) break;
+#if GNASH_DEBUG_REMOTING
const boost::uint32_t len = amf::readNetworkLong(b);
log_debug("Reported reply length %s", len);
+#endif
b += 4; // reply length
// this updates b to point to the next unparsed byte
http://git.savannah.gnu.org/cgit//commit/?id=3d72440aa3f550b3d93aac6aa3eb84ec5d02cd3d
commit 3d72440aa3f550b3d93aac6aa3eb84ec5d02cd3d
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 12:56:51 2010 +0200
Minor cleanups.
diff --git a/libcore/asobj/NetConnection_as.cpp
b/libcore/asobj/NetConnection_as.cpp
index e6a913d..eb85223 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -174,7 +174,7 @@ ConnectionHandler::getStream(const std::string&)
return std::auto_ptr<IOChannel>(0);
}
-//---- HTTPRemotingHandler (HTTPConnectionHandler)
-----------------------------------------------
+//---- HTTPRemotingHandler (HTTPConnectionHandler) ---
/// Queue of remoting calls
//
@@ -193,25 +193,18 @@ class HTTPRemotingHandler : public ConnectionHandler
{
public:
- /// Create an handler for HTTP remoting
+ /// Create a handler for HTTP remoting
//
- /// @param nc
- /// The NetConnection AS object to send status/error events to
- ///
- /// @param url
- /// URL to post calls to
- ///
+ /// @param nc The NetConnection AS object to send status/error events to
+ /// @param url URL to post calls to
HTTPRemotingHandler(NetConnection_as& nc, const URL& url);
- // See dox in ConnectionHandler
virtual bool hasPendingCalls() const {
return _connection || queued_count;
}
- // See dox in ConnectionHandler
virtual bool advance();
- // See dox in NetworkHandler class
virtual void call(as_object* asCallback, const std::string& methodName,
const std::vector<as_value>& args);
@@ -224,7 +217,7 @@ private:
boost::scoped_ptr<IOChannel> _connection;
SimpleBuffer _reply;
int _reply_start;
- int queued_count;
+ size_t queued_count;
// Quick hack to send Content-Type: application/x-amf
// TODO: check if we should take headers on a per-call basis
@@ -1210,15 +1203,15 @@ netconnection_new(const fn_call& fn)
}
-/// For rtmp, NetConnect.connect() takes an RTMP URL. For all other streams,
-/// it takes null or undefined.
+/// For remoting, NetConnection.connect() takes a URL. For all other streams,
+/// it takes null.
//
-/// RTMP is untested.
-//
-/// For non-rtmp streams:
+/// For non-remoting streams:
//
/// Returns undefined if there are no arguments, true if the first
-/// argument is null, otherwise the result of the attempted connection.
+/// argument is null, otherwise whether the connection is allowed. The
+/// actual result of the connection is sent with an onStatus call later.
+//
/// Undefined is also a valid argument for SWF7 and above.
//
/// The isConnected property is set to the result of connect().
http://git.savannah.gnu.org/cgit//commit/?id=afd2f99ccd0dde2a4e42948da4029459dd0fcc57
commit afd2f99ccd0dde2a4e42948da4029459dd0fcc57
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 12:39:14 2010 +0200
Reduce duplicated effort.
diff --git a/libcore/asobj/NetConnection_as.cpp
b/libcore/asobj/NetConnection_as.cpp
index 3df2cf5..e6a913d 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -274,7 +274,7 @@ HTTPRemotingHandler::advance()
_postdata.size());
#ifdef GNASH_DEBUG_REMOTING
log_debug("NetConnection.call(): encoded args from %1% calls: %2%",
- queued_count, hexify(_postdata.data(), _postdata.size(),
false));
+ queued_count, hexify(_postdata.data(), _postdata.size(), false));
#endif
queued_count = 0;
@@ -467,7 +467,7 @@ HTTPRemotingHandler::advance()
break;
}
- std::string methodName(
+ const std::string methodName(
reinterpret_cast<const char*>(b + ns + 1),
replylength - ns - 1);
@@ -688,7 +688,8 @@ public:
const RunResources& r = getRunResources(_nc.owner());
Global_as& gl = getGlobal(_nc.owner());
-
+
+ // Connection object
as_object* o = createObject(gl);
const int flags = 0;
@@ -709,15 +710,6 @@ public:
o->init_member("videoFunction", 1.0, flags);
o->init_member("pageUrl", as_value(), flags);
- const size_t id = callNo();
- SimpleBuffer buf;
-
- // Write the connect object.
- amf::Writer aw(buf);
- aw.writeString("connect");
- aw.writeNumber(id);
- aw.writeObject(o);
-
// Set up the callback object.
as_object* cb = createObject(getGlobal(_nc.owner()));
cb->init_member(NSV::PROP_ON_RESULT,
@@ -725,10 +717,10 @@ public:
cb->init_member("_conn", &_nc.owner(), 0);
- // When this call returns, the onResult function of the callback
- // handles onStatus etc.
- pushCallback(id, cb);
- _rtmp.call(buf);
+ std::vector<as_value> args;
+ args.push_back(o);
+
+ call(cb, "connect", args);
// Send bandwidth check; the pp appears to do this
// automatically.
@@ -797,7 +789,6 @@ RTMPRemotingHandler::handleInvoke(const boost::uint8_t*
payload,
as_value arg;
amf::Reader rd(payload, end, getGlobal(_nc.owner()));
-
// TODO: use all args and check the order! We currently only use
// the last one!
while (rd(arg)) {
http://git.savannah.gnu.org/cgit//commit/?id=e5d16688f150dd64f6b279dac85ccd9545395279
commit e5d16688f150dd64f6b279dac85ccd9545395279
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 12:04:23 2010 +0200
Minor cleanup.
diff --git a/libcore/asobj/NetConnection_as.cpp
b/libcore/asobj/NetConnection_as.cpp
index 97390ec..3df2cf5 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -327,7 +327,7 @@ HTTPRemotingHandler::advance()
_reply.resize(_reply.size() + read);
}
- // There is no way to tell if we have a whole amf _reply without
+ // There is no way to tell if we have a whole amf reply without
// parsing everything
//
// The reply format has a header field which specifies the
@@ -376,13 +376,12 @@ HTTPRemotingHandler::advance()
if (numheaders != 0) {
#ifdef GNASH_DEBUG_REMOTING
- log_debug("NetConnection::call(): amf headers "
- "section parsing");
+ log_debug("NetConnection::call(): amf headers section
parsing");
#endif
as_value tmp;
for (size_t i = numheaders; i > 0; --i) {
- if(b + 2 > end) {
- headers_ok = 0;
+ if (b + 2 > end) {
+ headers_ok = false;
break;
}
const boost::uint16_t namelength =
amf::readNetworkShort(b);
@@ -413,8 +412,7 @@ HTTPRemotingHandler::advance()
string_table& st = vm.getStringTable();
string_table::key key = st.find(headerName);
#ifdef GNASH_DEBUG_REMOTING
- log_debug("Calling NetConnection.%s(%s)",
- headerName, tmp);
+ log_debug("Calling NetConnection.%s(%s)", headerName, tmp);
#endif
callMethod(&_nc.owner(), key, tmp);
}
@@ -448,14 +446,13 @@ HTTPRemotingHandler::advance()
if (b + replylength > end) break;
// Reply message is: '/id/methodName'
-
int ns = 1; // next slash position
while (ns < replylength - 1 && *(b + ns) != '/') ++ns;
if (ns >= replylength - 1) {
std::string msg(reinterpret_cast<const char*>(b),
replylength);
log_error("NetConnection::call(): invalid "
- "_reply message name (%s)", msg);
+ "reply message name (%s)", msg);
break;
}
@@ -471,22 +468,23 @@ HTTPRemotingHandler::advance()
}
std::string methodName(
- reinterpret_cast<const char*>(b+ns+1),
+ reinterpret_cast<const char*>(b + ns + 1),
replylength - ns - 1);
b += replylength;
// parse past unused string in header
if (b + 2 > end) break;
- const boost::uint16_t unusedlength
- = amf::readNetworkShort(b);
+ const boost::uint16_t unusedlength =
+ amf::readNetworkShort(b);
+
b += 2;
if (b + unusedlength > end) break;
b += unusedlength;
// this field is supposed to hold the
// total number of bytes in the rest of
- // this particular _reply value, but
+ // this particular reply value, but
// openstreetmap.org (which works great
// in the adobe player) sends
// 0xffffffff. So we just ignore it
http://git.savannah.gnu.org/cgit//commit/?id=f82b8f90c356e5d67044979e9f255572a0374288
commit f82b8f90c356e5d67044979e9f255572a0374288
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 11:01:41 2010 +0200
Use sensible variable names and make them const.
diff --git a/libcore/asobj/NetConnection_as.cpp
b/libcore/asobj/NetConnection_as.cpp
index 5f52cec..97390ec 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -369,33 +369,34 @@ HTTPRemotingHandler::advance()
b += 2; // skip version indicator and client id
// NOTE: this looks much like parsing of an OBJECT_AMF0
- boost::int16_t si = amf::readNetworkShort(b);
+ const boost::uint16_t numheaders = amf::readNetworkShort(b);
b += 2; // number of headers
bool headers_ok = true;
- if (si != 0) {
+ if (numheaders != 0) {
#ifdef GNASH_DEBUG_REMOTING
log_debug("NetConnection::call(): amf headers "
"section parsing");
#endif
as_value tmp;
- for (size_t i = si; i > 0; --i) {
+ for (size_t i = numheaders; i > 0; --i) {
if(b + 2 > end) {
headers_ok = 0;
break;
}
- si = amf::readNetworkShort(b); b += 2; // name length
- if(b + si > end) {
+ const boost::uint16_t namelength =
amf::readNetworkShort(b);
+ b += 2;
+ if (b + namelength > end) {
headers_ok = false;
break;
}
- std::string headerName((char*)b, si); // end-b);
+ std::string headerName((char*)b, namelength);
#ifdef GNASH_DEBUG_REMOTING
log_debug("Header name %s", headerName);
#endif
- b += si;
- if ( b + 5 > end ) {
+ b += namelength;
+ if (b + 5 > end) {
headers_ok = false;
break;
}
@@ -421,32 +422,38 @@ HTTPRemotingHandler::advance()
if (headers_ok) {
- si = amf::readNetworkShort(b); b += 2; // number of replies
+ const boost::uint16_t numreplies = amf::readNetworkShort(b);
+ b += 2; // number of replies
// TODO consider counting number of replies we
// actually parse and doing something if it
// doesn't match this value (does it matter?
- if (si > 0) {
+ if (numreplies > 0) {
// parse replies until we get a parse error or
// we reach the end of the buffer
while (b < end) {
- if(b + 2 > end) break;
- si = amf::readNetworkShort(b);
- b += 2; // _reply length
- if(si < 4) { // shorted valid response is '/1/a'
+
+ if (b + 2 > end) break;
+
+ const boost::uint16_t replylength =
+ amf::readNetworkShort(b);
+ b += 2;
+
+ if (replylength < 4) {
+ // shortest valid response is '/1/a'
log_error("NetConnection::call(): "
- "_reply message name too short");
+ "reply message name too short");
break;
}
- if (b + si > end) break;
+ if (b + replylength > end) break;
// Reply message is: '/id/methodName'
int ns = 1; // next slash position
- while (ns < si - 1 && *(b + ns) != '/') ++ns;
- if (ns >= si - 1) {
- std::string msg(
- reinterpret_cast<const char*>(b), si);
+ while (ns < replylength - 1 && *(b + ns) != '/') ++ns;
+ if (ns >= replylength - 1) {
+ std::string msg(reinterpret_cast<const char*>(b),
+ replylength);
log_error("NetConnection::call(): invalid "
"_reply message name (%s)", msg);
break;
@@ -465,16 +472,17 @@ HTTPRemotingHandler::advance()
std::string methodName(
reinterpret_cast<const char*>(b+ns+1),
- si-ns-1);
+ replylength - ns - 1);
- b += si;
+ b += replylength;
// parse past unused string in header
if (b + 2 > end) break;
- si = amf::readNetworkShort(b);
- b += 2; // _reply length
- if (b + si > end) break;
- b += si;
+ const boost::uint16_t unusedlength
+ = amf::readNetworkShort(b);
+ b += 2;
+ if (b + unusedlength > end) break;
+ b += unusedlength;
// this field is supposed to hold the
// total number of bytes in the rest of
http://git.savannah.gnu.org/cgit//commit/?id=052597c426e091866827c12074e727a9781b81f2
commit 052597c426e091866827c12074e727a9781b81f2
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 10:55:01 2010 +0200
Fix silly variables and scopes.
diff --git a/libcore/asobj/NetConnection_as.cpp
b/libcore/asobj/NetConnection_as.cpp
index d27f522..5f52cec 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -330,16 +330,15 @@ HTTPRemotingHandler::advance()
// There is no way to tell if we have a whole amf _reply without
// parsing everything
//
- // The _reply format has a header field which specifies the
- // number of bytes in the _reply, but potlatch sends 0xffffffff
+ // The reply format has a header field which specifies the
+ // number of bytes in the reply, but potlatch sends 0xffffffff
// and works fine in the proprietary player
//
- // For now we just wait until we have the full _reply.
+ // For now we just wait until we have the full reply.
//
// FIXME make this parse on other conditions, including: 1) when
// the buffer is full, 2) when we have a "length in bytes" value
// thas is satisfied
-
if (_connection->bad()) {
log_debug("connection is in error condition, calling "
"NetConnection.onStatus");
@@ -351,16 +350,16 @@ HTTPRemotingHandler::advance()
// This is just a guess, but is better than sending
// 'undefined'
_nc.notifyStatus(NetConnection_as::CALL_FAILED);
+ return false;
}
- else if (_connection->eof()) {
+
+ if (_connection->eof()) {
if (_reply.size() > 8) {
-
#ifdef GNASH_DEBUG_REMOTING
log_debug("hit eof");
#endif
- boost::uint16_t li;
const boost::uint8_t *b = _reply.data() + _reply_start;
const boost::uint8_t *end = _reply.data() + _reply.size();
@@ -372,7 +371,8 @@ HTTPRemotingHandler::advance()
// NOTE: this looks much like parsing of an OBJECT_AMF0
boost::int16_t si = amf::readNetworkShort(b);
b += 2; // number of headers
- uint8_t headers_ok = 1;
+
+ bool headers_ok = true;
if (si != 0) {
#ifdef GNASH_DEBUG_REMOTING
@@ -387,7 +387,7 @@ HTTPRemotingHandler::advance()
}
si = amf::readNetworkShort(b); b += 2; // name length
if(b + si > end) {
- headers_ok = 0;
+ headers_ok = false;
break;
}
std::string headerName((char*)b, si); // end-b);
@@ -396,43 +396,40 @@ HTTPRemotingHandler::advance()
#endif
b += si;
if ( b + 5 > end ) {
- headers_ok = 0;
+ headers_ok = false;
break;
}
b += 5; // skip past bool and length long
- if(!rd(tmp)) {
- headers_ok = 0;
+
+ if (!rd(tmp)) {
+ headers_ok = false;
break;
}
#ifdef GNASH_DEBUG_REMOTING
log_debug("Header value %s", tmp);
#endif
-
- { // method call for each header
- // FIXME: it seems to me that the call should happen
- VM& vm = getVM(_nc.owner());
- string_table& st = vm.getStringTable();
- string_table::key key = st.find(headerName);
+ VM& vm = getVM(_nc.owner());
+ string_table& st = vm.getStringTable();
+ string_table::key key = st.find(headerName);
#ifdef GNASH_DEBUG_REMOTING
- log_debug("Calling NetConnection.%s(%s)",
- headerName, tmp);
+ log_debug("Calling NetConnection.%s(%s)",
+ headerName, tmp);
#endif
- callMethod(&_nc.owner(), key, tmp);
- }
+ callMethod(&_nc.owner(), key, tmp);
}
}
- if(headers_ok == 1) {
+ if (headers_ok) {
si = amf::readNetworkShort(b); b += 2; // number of replies
// TODO consider counting number of replies we
// actually parse and doing something if it
// doesn't match this value (does it matter?
- if(si > 0) {
+ if (si > 0) {
// parse replies until we get a parse error or
// we reach the end of the buffer
- while(b < end) {
+ while (b < end) {
if(b + 2 > end) break;
si = amf::readNetworkShort(b);
b += 2; // _reply length
@@ -486,12 +483,13 @@ HTTPRemotingHandler::advance()
// in the adobe player) sends
// 0xffffffff. So we just ignore it
if (b + 4 > end) break;
- li = amf::readNetworkLong(b);
- b += 4; // _reply length
+ const boost::uint32_t len = amf::readNetworkLong(b);
+ log_debug("Reported reply length %s", len);
+ b += 4; // reply length
// this updates b to point to the next unparsed byte
- as_value _replyval;
- if (!rd(_replyval)) {
+ as_value replyval;
+ if (!rd(replyval)) {
log_error("parse amf failed");
// this will happen if we get
// bogus data, or if the data runs
@@ -510,7 +508,7 @@ HTTPRemotingHandler::advance()
if (callback) {
string_table::key methodKey;
- if ( methodName == "onResult" ) {
+ if (methodName == "onResult") {
methodKey = NSV::PROP_ON_RESULT;
}
else if (methodName == "onStatus") {
@@ -532,12 +530,14 @@ HTTPRemotingHandler::advance()
#endif
// FIXME check if above line can fail and we
// have to react
- callMethod(callback, methodKey, _replyval);
+ callMethod(callback, methodKey, replyval);
#ifdef GNASH_DEBUG_REMOTING
log_debug("callback called");
#endif
- } else {
- log_error("Unknown HTTP Remoting response
identifier '%s'", id);
+ }
+ else {
+ log_error("Unknown HTTP Remoting response "
+ "identifier '%s'", id);
}
}
}
http://git.savannah.gnu.org/cgit//commit/?id=23bc396aabf94aead11b4f552b789e77a29eb1ef
commit 23bc396aabf94aead11b4f552b789e77a29eb1ef
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 10:43:35 2010 +0200
Reorder advance() logic to make the function more readable.
diff --git a/libcore/asobj/NetConnection_as.cpp
b/libcore/asobj/NetConnection_as.cpp
index 3828773..d27f522 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -259,305 +259,300 @@ bool
HTTPRemotingHandler::advance()
{
- if (_connection) {
+ // If there is no active connection, check whether messages are waiting
+ if (!_connection) {
- // Fill last chunk before reading in the next
- size_t toRead = _reply.capacity() - _reply.size();
- if (!toRead) toRead = NCCALLREPLYCHUNK;
+ // If there is nothing to send, there's no more to do.
+ if (!queued_count) return false;
+ log_debug("creating connection");
+
+ (reinterpret_cast<boost::uint16_t*>(_postdata.data() + 4))[0] =
+ htons(queued_count);
+
+ std::string postdata_str(reinterpret_cast<char*>(_postdata.data()),
+ _postdata.size());
#ifdef GNASH_DEBUG_REMOTING
- log_debug("Attempt to read %d bytes", toRead);
+ log_debug("NetConnection.call(): encoded args from %1% calls: %2%",
+ queued_count, hexify(_postdata.data(), _postdata.size(),
false));
#endif
+ queued_count = 0;
- // See if we need to allocate more bytes for the next
- // read chunk
- if (_reply.capacity() < _reply.size() + toRead) {
- // if _connection->size() >= 0, reserve for it, so
- // if HTTP Content-Length response header is correct
- // we'll be allocating only once for all.
- const size_t newCapacity = _reply.size() + toRead;
+ // TODO: it might be useful for a Remoting Handler to have a
+ // StreamProvider member
+ const StreamProvider& sp =
+ getRunResources(_nc.owner()).streamProvider();
+
+ _connection.reset(sp.getStream(_url, postdata_str,
_headers).release());
+
+ _postdata.resize(6);
+
+ return true;
+ }
+
+ // Fill last chunk before reading in the next
+ size_t toRead = _reply.capacity() - _reply.size();
+ if (!toRead) toRead = NCCALLREPLYCHUNK;
#ifdef GNASH_DEBUG_REMOTING
- log_debug("NetConnection.call: reply buffer capacity (%d) "
- "is too small to accept next %d bytes of chunk "
- "(current size is %d). Reserving %d bytes.",
- _reply.capacity(), toRead, _reply.size(), newCapacity);
+ log_debug("Attempt to read %d bytes", toRead);
#endif
- _reply.reserve(newCapacity);
- }
+ // See if we need to allocate more bytes for the next
+ // read chunk
+ if (_reply.capacity() < _reply.size() + toRead) {
+ // if _connection->size() >= 0, reserve for it, so
+ // if HTTP Content-Length response header is correct
+ // we'll be allocating only once for all.
+ const size_t newCapacity = _reply.size() + toRead;
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("NetConnection.call: reply buffer capacity (%d) "
+ "is too small to accept next %d bytes of chunk "
+ "(current size is %d). Reserving %d bytes.",
+ _reply.capacity(), toRead, _reply.size(), newCapacity);
+#endif
+
+ _reply.reserve(newCapacity);
+ }
- const int read =
- _connection->readNonBlocking(_reply.data() + _reply.size(),
toRead);
+ const int read =
+ _connection->readNonBlocking(_reply.data() + _reply.size(), toRead);
- if (read > 0) {
+ if (read > 0) {
#ifdef GNASH_DEBUG_REMOTING
- log_debug("read '%1%' bytes: %2%", read,
- hexify(_reply.data() + _reply.size(), read, false));
+ log_debug("read '%1%' bytes: %2%", read,
+ hexify(_reply.data() + _reply.size(), read, false));
#endif
- _reply.resize(_reply.size() + read);
- }
+ _reply.resize(_reply.size() + read);
+ }
- // There is no way to tell if we have a whole amf _reply without
- // parsing everything
- //
- // The _reply format has a header field which specifies the
- // number of bytes in the _reply, but potlatch sends 0xffffffff
- // and works fine in the proprietary player
- //
- // For now we just wait until we have the full _reply.
- //
- // FIXME make this parse on other conditions, including: 1) when
- // the buffer is full, 2) when we have a "length in bytes" value
- // thas is satisfied
-
- if (_connection->bad()) {
- log_debug("connection is in error condition, calling "
- "NetConnection.onStatus");
- _reply.resize(0);
- _reply_start = 0;
- // reset connection before calling the callback
- _connection.reset();
-
- // This is just a guess, but is better than sending
- // 'undefined'
- _nc.notifyStatus(NetConnection_as::CALL_FAILED);
- }
- else if (_connection->eof()) {
+ // There is no way to tell if we have a whole amf _reply without
+ // parsing everything
+ //
+ // The _reply format has a header field which specifies the
+ // number of bytes in the _reply, but potlatch sends 0xffffffff
+ // and works fine in the proprietary player
+ //
+ // For now we just wait until we have the full _reply.
+ //
+ // FIXME make this parse on other conditions, including: 1) when
+ // the buffer is full, 2) when we have a "length in bytes" value
+ // thas is satisfied
+
+ if (_connection->bad()) {
+ log_debug("connection is in error condition, calling "
+ "NetConnection.onStatus");
+ _reply.resize(0);
+ _reply_start = 0;
+ // reset connection before calling the callback
+ _connection.reset();
+
+ // This is just a guess, but is better than sending
+ // 'undefined'
+ _nc.notifyStatus(NetConnection_as::CALL_FAILED);
+ }
+ else if (_connection->eof()) {
- if (_reply.size() > 8) {
+ if (_reply.size() > 8) {
#ifdef GNASH_DEBUG_REMOTING
- log_debug("hit eof");
+ log_debug("hit eof");
#endif
- boost::uint16_t li;
- const boost::uint8_t *b = _reply.data() + _reply_start;
- const boost::uint8_t *end = _reply.data() + _reply.size();
-
- amf::Reader rd(b, end, getGlobal(_nc.owner()));
+ boost::uint16_t li;
+ const boost::uint8_t *b = _reply.data() + _reply_start;
+ const boost::uint8_t *end = _reply.data() + _reply.size();
+
+ amf::Reader rd(b, end, getGlobal(_nc.owner()));
- // parse header
- b += 2; // skip version indicator and client id
+ // parse header
+ b += 2; // skip version indicator and client id
- // NOTE: this looks much like parsing of an OBJECT_AMF0
- boost::int16_t si = amf::readNetworkShort(b);
- b += 2; // number of headers
- uint8_t headers_ok = 1;
- if (si != 0) {
+ // NOTE: this looks much like parsing of an OBJECT_AMF0
+ boost::int16_t si = amf::readNetworkShort(b);
+ b += 2; // number of headers
+ uint8_t headers_ok = 1;
+ if (si != 0) {
#ifdef GNASH_DEBUG_REMOTING
- log_debug("NetConnection::call(): amf headers "
- "section parsing");
+ log_debug("NetConnection::call(): amf headers "
+ "section parsing");
#endif
- as_value tmp;
- for (size_t i = si; i > 0; --i) {
- if(b + 2 > end) {
- headers_ok = 0;
- break;
- }
- si = amf::readNetworkShort(b); b += 2; // name length
- if(b + si > end) {
- headers_ok = 0;
- break;
- }
- std::string headerName((char*)b, si); // end-b);
+ as_value tmp;
+ for (size_t i = si; i > 0; --i) {
+ if(b + 2 > end) {
+ headers_ok = 0;
+ break;
+ }
+ si = amf::readNetworkShort(b); b += 2; // name length
+ if(b + si > end) {
+ headers_ok = 0;
+ break;
+ }
+ std::string headerName((char*)b, si); // end-b);
#ifdef GNASH_DEBUG_REMOTING
- log_debug("Header name %s", headerName);
+ log_debug("Header name %s", headerName);
#endif
- b += si;
- if ( b + 5 > end ) {
- headers_ok = 0;
- break;
- }
- b += 5; // skip past bool and length long
- if(!rd(tmp)) {
- headers_ok = 0;
- break;
- }
+ b += si;
+ if ( b + 5 > end ) {
+ headers_ok = 0;
+ break;
+ }
+ b += 5; // skip past bool and length long
+ if(!rd(tmp)) {
+ headers_ok = 0;
+ break;
+ }
#ifdef GNASH_DEBUG_REMOTING
- log_debug("Header value %s", tmp);
+ log_debug("Header value %s", tmp);
#endif
- { // method call for each header
- // FIXME: it seems to me that the call should happen
- VM& vm = getVM(_nc.owner());
- string_table& st = vm.getStringTable();
- string_table::key key = st.find(headerName);
+ { // method call for each header
+ // FIXME: it seems to me that the call should happen
+ VM& vm = getVM(_nc.owner());
+ string_table& st = vm.getStringTable();
+ string_table::key key = st.find(headerName);
#ifdef GNASH_DEBUG_REMOTING
- log_debug("Calling NetConnection.%s(%s)",
- headerName, tmp);
+ log_debug("Calling NetConnection.%s(%s)",
+ headerName, tmp);
#endif
- callMethod(&_nc.owner(), key, tmp);
- }
+ callMethod(&_nc.owner(), key, tmp);
}
}
+ }
- if(headers_ok == 1) {
-
- si = amf::readNetworkShort(b); b += 2; // number of replies
-
- // TODO consider counting number of replies we
- // actually parse and doing something if it
- // doesn't match this value (does it matter?
- if(si > 0) {
- // parse replies until we get a parse error or
- // we reach the end of the buffer
- while(b < end) {
- if(b + 2 > end) break;
- si = amf::readNetworkShort(b);
- b += 2; // _reply length
- if(si < 4) { // shorted valid response is '/1/a'
- log_error("NetConnection::call(): "
- "_reply message name too short");
- break;
- }
- if (b + si > end) break;
-
- // Reply message is: '/id/methodName'
-
- int ns = 1; // next slash position
- while (ns < si - 1 && *(b + ns) != '/') ++ns;
- if (ns >= si - 1) {
- std::string msg(
- reinterpret_cast<const char*>(b), si);
- log_error("NetConnection::call(): invalid "
- "_reply message name (%s)", msg);
- break;
- }
+ if(headers_ok == 1) {
+
+ si = amf::readNetworkShort(b); b += 2; // number of replies
+
+ // TODO consider counting number of replies we
+ // actually parse and doing something if it
+ // doesn't match this value (does it matter?
+ if(si > 0) {
+ // parse replies until we get a parse error or
+ // we reach the end of the buffer
+ while(b < end) {
+ if(b + 2 > end) break;
+ si = amf::readNetworkShort(b);
+ b += 2; // _reply length
+ if(si < 4) { // shorted valid response is '/1/a'
+ log_error("NetConnection::call(): "
+ "_reply message name too short");
+ break;
+ }
+ if (b + si > end) break;
+
+ // Reply message is: '/id/methodName'
+
+ int ns = 1; // next slash position
+ while (ns < si - 1 && *(b + ns) != '/') ++ns;
+ if (ns >= si - 1) {
+ std::string msg(
+ reinterpret_cast<const char*>(b), si);
+ log_error("NetConnection::call(): invalid "
+ "_reply message name (%s)", msg);
+ break;
+ }
+
+ std::string id(reinterpret_cast<const char*>(b + 1),
+ ns - 1);
+ size_t callbackID = 0;
+ try {
+ callbackID = boost::lexical_cast<size_t>(id);
+ }
+ catch (const boost::bad_lexical_cast&) {
+ log_error(_("Callback ID was not a number"));
+ break;
+ }
+
+ std::string methodName(
+ reinterpret_cast<const char*>(b+ns+1),
+ si-ns-1);
- std::string id(reinterpret_cast<const char*>(b +
1),
- ns - 1);
- size_t callbackID = 0;
- try {
- callbackID = boost::lexical_cast<size_t>(id);
+ b += si;
+
+ // parse past unused string in header
+ if (b + 2 > end) break;
+ si = amf::readNetworkShort(b);
+ b += 2; // _reply length
+ if (b + si > end) break;
+ b += si;
+
+ // this field is supposed to hold the
+ // total number of bytes in the rest of
+ // this particular _reply value, but
+ // openstreetmap.org (which works great
+ // in the adobe player) sends
+ // 0xffffffff. So we just ignore it
+ if (b + 4 > end) break;
+ li = amf::readNetworkLong(b);
+ b += 4; // _reply length
+
+ // this updates b to point to the next unparsed byte
+ as_value _replyval;
+ if (!rd(_replyval)) {
+ log_error("parse amf failed");
+ // this will happen if we get
+ // bogus data, or if the data runs
+ // off the end of the buffer
+ // provided, or if we get data we
+ // don't know how to parse
+ break;
+ }
+
+ // update variable to show how much we've parsed
+ _reply_start = b - _reply.data();
+
+ // if actionscript specified a callback object,
+ // call it
+ as_object* callback = popCallback(callbackID);
+ if (callback) {
+
+ string_table::key methodKey;
+ if ( methodName == "onResult" ) {
+ methodKey = NSV::PROP_ON_RESULT;
}
- catch (const boost::bad_lexical_cast&) {
- log_error(_("Callback ID was not a number"));
- break;
+ else if (methodName == "onStatus") {
+ methodKey = NSV::PROP_ON_STATUS;
}
-
- std::string methodName(
- reinterpret_cast<const char*>(b+ns+1),
- si-ns-1);
-
- b += si;
-
- // parse past unused string in header
- if (b + 2 > end) break;
- si = amf::readNetworkShort(b);
- b += 2; // _reply length
- if (b + si > end) break;
- b += si;
-
- // this field is supposed to hold the
- // total number of bytes in the rest of
- // this particular _reply value, but
- // openstreetmap.org (which works great
- // in the adobe player) sends
- // 0xffffffff. So we just ignore it
- if (b + 4 > end) break;
- li = amf::readNetworkLong(b);
- b += 4; // _reply length
-
- // this updates b to point to the next unparsed
byte
- as_value _replyval;
- if (!rd(_replyval)) {
- log_error("parse amf failed");
- // this will happen if we get
- // bogus data, or if the data runs
- // off the end of the buffer
- // provided, or if we get data we
- // don't know how to parse
- break;
+ else {
+ // NOTE: the pp is known to actually
+ // invoke the custom method, but with 7
+ // undefined arguments (?)
+ log_error("Unsupported HTTP Remoting "
+ "response callback: '%s' "
+ "(size %d)", methodName,
+ methodName.size());
+ continue;
}
- // update variable to show how much we've parsed
- _reply_start = b - _reply.data();
-
- // if actionscript specified a callback object,
- // call it
- as_object* callback = popCallback(callbackID);
- if (callback) {
-
- string_table::key methodKey;
- if ( methodName == "onResult" ) {
- methodKey = NSV::PROP_ON_RESULT;
- }
- else if (methodName == "onStatus") {
- methodKey = NSV::PROP_ON_STATUS;
- }
- else {
- // NOTE: the pp is known to actually
- // invoke the custom method, but with 7
- // undefined arguments (?)
- log_error("Unsupported HTTP Remoting "
- "response callback: '%s' "
- "(size %d)", methodName,
- methodName.size());
- continue;
- }
-
#ifdef GNASH_DEBUG_REMOTING
- log_debug("calling onResult callback");
+ log_debug("calling onResult callback");
#endif
- // FIXME check if above line can fail and we
- // have to react
- callMethod(callback, methodKey, _replyval);
+ // FIXME check if above line can fail and we
+ // have to react
+ callMethod(callback, methodKey, _replyval);
#ifdef GNASH_DEBUG_REMOTING
- log_debug("callback called");
+ log_debug("callback called");
#endif
- } else {
- log_error("Unknown HTTP Remoting response
identifier '%s'", id);
- }
+ } else {
+ log_error("Unknown HTTP Remoting response
identifier '%s'", id);
}
}
}
}
- else {
- log_error("Response from remoting service < 8 bytes");
- }
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("deleting connection");
-#endif
- _connection.reset();
- _reply.resize(0);
- _reply_start = 0;
}
- }
-
- if (!_connection && queued_count > 0) {
- log_debug("creating connection");
- // set the "number of bodies" header
-
- (reinterpret_cast<boost::uint16_t*>(_postdata.data() + 4))[0] =
- htons(queued_count);
-
- std::string postdata_str(reinterpret_cast<char*>(_postdata.data()),
- _postdata.size());
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("NetConnection.call(): encoded args from %1% calls: %2%",
- queued_count, hexify(_postdata.data(), _postdata.size(),
false));
-#endif
- queued_count = 0;
-
- // TODO: it might be useful for a Remoting Handler to have a
- // StreamProvider member
- const StreamProvider& sp =
- getRunResources(_nc.owner()).streamProvider();
-
- _connection.reset(sp.getStream(_url, postdata_str,
_headers).release());
+ else {
+ log_error("Response from remoting service < 8 bytes");
+ }
- _postdata.resize(6);
#ifdef GNASH_DEBUG_REMOTING
- log_debug("connection created");
+ log_debug("deleting connection");
#endif
- }
-
- if (_connection == 0) {
- // nothing more to do
- return false;
+ _connection.reset();
+ _reply.resize(0);
+ _reply_start = 0;
}
return true;
http://git.savannah.gnu.org/cgit//commit/?id=f85abb39021eeded3f92c066851e26496e19e25d
commit f85abb39021eeded3f92c066851e26496e19e25d
Author: Benjamin Wolsey <address@hidden>
Date: Wed Oct 27 10:10:57 2010 +0200
Renames and silence debugging.
diff --git a/libcore/asobj/NetConnection_as.cpp
b/libcore/asobj/NetConnection_as.cpp
index c2605f2..3828773 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -222,14 +222,13 @@ private:
SimpleBuffer _postdata;
URL _url;
boost::scoped_ptr<IOChannel> _connection;
- SimpleBuffer reply;
- int reply_start;
+ SimpleBuffer _reply;
+ int _reply_start;
int queued_count;
// Quick hack to send Content-Type: application/x-amf
// TODO: check if we should take headers on a per-call basis
// due to NetConnection.addHeader.
- //
NetworkAdapter::RequestHeaders _headers;
void push_amf(const SimpleBuffer &amf) {
@@ -245,13 +244,13 @@
HTTPRemotingHandler::HTTPRemotingHandler(NetConnection_as& nc, const URL& url)
_postdata(),
_url(url),
_connection(0),
- reply(),
- reply_start(0),
+ _reply(),
+ _reply_start(0),
queued_count(0)
{
// leave space for header
_postdata.append("\000\000\000\000\000\000", 6);
- assert(reply.size() == 0);
+ assert(_reply.size() == 0);
_headers["Content-Type"] = "application/x-amf";
}
@@ -263,7 +262,7 @@ HTTPRemotingHandler::advance()
if (_connection) {
// Fill last chunk before reading in the next
- size_t toRead = reply.capacity() - reply.size();
+ size_t toRead = _reply.capacity() - _reply.size();
if (!toRead) toRead = NCCALLREPLYCHUNK;
#ifdef GNASH_DEBUG_REMOTING
@@ -272,45 +271,41 @@ HTTPRemotingHandler::advance()
// See if we need to allocate more bytes for the next
// read chunk
- if (reply.capacity() < reply.size() + toRead) {
+ if (_reply.capacity() < _reply.size() + toRead) {
// if _connection->size() >= 0, reserve for it, so
// if HTTP Content-Length response header is correct
// we'll be allocating only once for all.
- const size_t newCapacity = reply.size() + toRead;
+ const size_t newCapacity = _reply.size() + toRead;
#ifdef GNASH_DEBUG_REMOTING
log_debug("NetConnection.call: reply buffer capacity (%d) "
"is too small to accept next %d bytes of chunk "
"(current size is %d). Reserving %d bytes.",
- reply.capacity(), toRead, reply.size(), newCapacity);
+ _reply.capacity(), toRead, _reply.size(), newCapacity);
#endif
- reply.reserve(newCapacity);
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug(" after reserve, new capacity is %d", reply.capacity());
-#endif
+ _reply.reserve(newCapacity);
}
const int read =
- _connection->readNonBlocking(reply.data() + reply.size(), toRead);
+ _connection->readNonBlocking(_reply.data() + _reply.size(),
toRead);
if (read > 0) {
#ifdef GNASH_DEBUG_REMOTING
log_debug("read '%1%' bytes: %2%", read,
- hexify(reply.data() + reply.size(), read, false));
+ hexify(_reply.data() + _reply.size(), read, false));
#endif
- reply.resize(reply.size() + read);
+ _reply.resize(_reply.size() + read);
}
- // There is no way to tell if we have a whole amf reply without
+ // There is no way to tell if we have a whole amf _reply without
// parsing everything
//
- // The reply format has a header field which specifies the
- // number of bytes in the reply, but potlatch sends 0xffffffff
+ // The _reply format has a header field which specifies the
+ // number of bytes in the _reply, but potlatch sends 0xffffffff
// and works fine in the proprietary player
//
- // For now we just wait until we have the full reply.
+ // For now we just wait until we have the full _reply.
//
// FIXME make this parse on other conditions, including: 1) when
// the buffer is full, 2) when we have a "length in bytes" value
@@ -319,8 +314,8 @@ HTTPRemotingHandler::advance()
if (_connection->bad()) {
log_debug("connection is in error condition, calling "
"NetConnection.onStatus");
- reply.resize(0);
- reply_start = 0;
+ _reply.resize(0);
+ _reply_start = 0;
// reset connection before calling the callback
_connection.reset();
@@ -330,15 +325,15 @@ HTTPRemotingHandler::advance()
}
else if (_connection->eof()) {
- if (reply.size() > 8) {
+ if (_reply.size() > 8) {
#ifdef GNASH_DEBUG_REMOTING
log_debug("hit eof");
#endif
boost::uint16_t li;
- const boost::uint8_t *b = reply.data() + reply_start;
- const boost::uint8_t *end = reply.data() + reply.size();
+ const boost::uint8_t *b = _reply.data() + _reply_start;
+ const boost::uint8_t *end = _reply.data() + _reply.size();
amf::Reader rd(b, end, getGlobal(_nc.owner()));
@@ -411,10 +406,10 @@ HTTPRemotingHandler::advance()
while(b < end) {
if(b + 2 > end) break;
si = amf::readNetworkShort(b);
- b += 2; // reply length
+ b += 2; // _reply length
if(si < 4) { // shorted valid response is '/1/a'
log_error("NetConnection::call(): "
- "reply message name too short");
+ "_reply message name too short");
break;
}
if (b + si > end) break;
@@ -427,7 +422,7 @@ HTTPRemotingHandler::advance()
std::string msg(
reinterpret_cast<const char*>(b), si);
log_error("NetConnection::call(): invalid "
- "reply message name (%s)", msg);
+ "_reply message name (%s)", msg);
break;
}
@@ -451,23 +446,23 @@ HTTPRemotingHandler::advance()
// parse past unused string in header
if (b + 2 > end) break;
si = amf::readNetworkShort(b);
- b += 2; // reply length
+ b += 2; // _reply length
if (b + si > end) break;
b += si;
// this field is supposed to hold the
// total number of bytes in the rest of
- // this particular reply value, but
+ // this particular _reply value, but
// openstreetmap.org (which works great
// in the adobe player) sends
// 0xffffffff. So we just ignore it
if (b + 4 > end) break;
li = amf::readNetworkLong(b);
- b += 4; // reply length
+ b += 4; // _reply length
// this updates b to point to the next unparsed
byte
- as_value replyval;
- if (!rd(replyval)) {
+ as_value _replyval;
+ if (!rd(_replyval)) {
log_error("parse amf failed");
// this will happen if we get
// bogus data, or if the data runs
@@ -478,7 +473,7 @@ HTTPRemotingHandler::advance()
}
// update variable to show how much we've parsed
- reply_start = b - reply.data();
+ _reply_start = b - _reply.data();
// if actionscript specified a callback object,
// call it
@@ -508,7 +503,7 @@ HTTPRemotingHandler::advance()
#endif
// FIXME check if above line can fail and we
// have to react
- callMethod(callback, methodKey, replyval);
+ callMethod(callback, methodKey, _replyval);
#ifdef GNASH_DEBUG_REMOTING
log_debug("callback called");
#endif
@@ -527,8 +522,8 @@ HTTPRemotingHandler::advance()
log_debug("deleting connection");
#endif
_connection.reset();
- reply.resize(0);
- reply_start = 0;
+ _reply.resize(0);
+ _reply_start = 0;
}
}
@@ -1076,14 +1071,12 @@ void
NetConnection_as::startAdvanceTimer()
{
getRoot(owner()).addAdvanceCallback(this);
- log_debug("startAdvanceTimer: registered NetConnection timer");
}
void
NetConnection_as::stopAdvanceTimer()
{
getRoot(owner()).removeAdvanceCallback(this);
- log_debug("stopAdvanceTimer: deregistered NetConnection timer");
}
void
@@ -1103,7 +1096,7 @@ NetConnection_as::update()
delete ch;
}
- else break; // queues handling is serialized
+ else break;
}
if (_currentConnection.get()) {
@@ -1114,13 +1107,7 @@ NetConnection_as::update()
// of a new connection, so we won't stop the advance
// timer in that case
if (_queuedConnections.empty() && !_currentConnection.get()) {
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("stopping advance timer");
-#endif
stopAdvanceTimer();
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("advance timer stopped");
-#endif
}
}
-----------------------------------------------------------------------
Summary of changes:
libcore/asobj/NetConnection_as.cpp | 568 +++++++++++++++++-------------------
1 files changed, 271 insertions(+), 297 deletions(-)
hooks/post-receive
--
Gnash
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] [SCM] Gnash branch, master, updated. 7b1ae9f0b3846d953a0d91ef4b02517f9917ebbf,
Benjamin Wolsey <=