1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Michael Hackstein 2013-05-21 14:03:14 +02:00
commit 052eced1a5
26 changed files with 99 additions and 45 deletions

View File

@ -103,7 +103,7 @@ bool RestActionHandler::isDirect () {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& RestActionHandler::queue () {
string const& RestActionHandler::queue () const {
return _queue;
}

View File

@ -126,7 +126,7 @@ namespace triagens {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& queue ();
string const& queue () const;
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}

View File

@ -437,10 +437,13 @@ TRI_aql_node_t* TRI_CreateNodeVariableAql (TRI_aql_context_t* const context,
ABORT_OOM
}
if (! TRI_AddVariableScopeAql(context, name, definingNode)) {
// duplicate variable name
TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_VARIABLE_REDECLARED, name);
return NULL;
// if not a temporary variable
if (*name != '_') {
if (! TRI_AddVariableScopeAql(context, name, definingNode)) {
// duplicate variable name
TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_VARIABLE_REDECLARED, name);
return NULL;
}
}
TRI_AQL_NODE_STRING(node) = (char*) name;

View File

@ -87,7 +87,7 @@ bool RestBatchHandler::isDirect () {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& RestBatchHandler::queue () {
string const& RestBatchHandler::queue () const {
static string const client = "STANDARD";
return client;

View File

@ -153,7 +153,7 @@ namespace triagens {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& queue ();
string const& queue () const;
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}

View File

@ -85,7 +85,7 @@ bool RestDocumentHandler::isDirect () {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& RestDocumentHandler::queue () {
string const& RestDocumentHandler::queue () const {
static string const client = "STANDARD";
return client;

View File

@ -94,7 +94,7 @@ namespace triagens {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& queue ();
string const& queue () const;
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}

View File

@ -83,7 +83,7 @@ bool RestImportHandler::isDirect () {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& RestImportHandler::queue () {
string const& RestImportHandler::queue () const {
static string const client = "STANDARD";
return client;

View File

@ -94,7 +94,7 @@ namespace triagens {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& queue ();
string const& queue () const;
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}

View File

@ -87,7 +87,7 @@ bool RestUploadHandler::isDirect () {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& RestUploadHandler::queue () {
string const& RestUploadHandler::queue () const {
static string const client = "STANDARD";
return client;

View File

@ -105,7 +105,7 @@ namespace triagens {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& queue ();
string const& queue () const;
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}

View File

@ -235,18 +235,14 @@ static void MoveHeader (TRI_headers_t* h,
headers->_begin = header;
}
else if (headers->_begin == header) {
if (header->_next != NULL) {
headers->_begin = header->_next;
}
headers->_begin = header->_next;
}
if (old->_next == NULL) {
headers->_end = header;
}
else if (headers->_end == header) {
if (header->_prev != NULL) {
headers->_end = header->_prev;
}
headers->_end = header->_prev;
}
if (header->_prev != NULL) {

View File

@ -84,7 +84,7 @@ bool RestVersionHandler::isDirect () {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& RestVersionHandler::queue () {
string const& RestVersionHandler::queue () const {
return _queue;
}

View File

@ -122,7 +122,7 @@ namespace triagens {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
string const& queue ();
string const& queue () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the server version number

View File

@ -182,6 +182,14 @@ namespace triagens {
return TRI_EndStringBuffer(&_buffer);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns pointer to the end of the character buffer
////////////////////////////////////////////////////////////////////////////////
char * end () {
return const_cast<char*>(TRI_EndStringBuffer(&_buffer));
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns length of the character buffer
////////////////////////////////////////////////////////////////////////////////
@ -190,6 +198,14 @@ namespace triagens {
return TRI_LengthStringBuffer(&_buffer);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief increases length of the character buffer
////////////////////////////////////////////////////////////////////////////////
void increaseLength (size_t n) {
TRI_IncreaseLengthStringBuffer(&_buffer, n);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns true if buffer is empty
////////////////////////////////////////////////////////////////////////////////
@ -257,7 +273,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- STRING AND CHARATCER APPENDERS
// --SECTION-- STRING AND CHARACTER APPENDERS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -167,6 +167,9 @@ static void RemoveAllLockedFiles (void) {
TRI_RemoveVector(&FileDescriptors, i);
}
TRI_DestroyVectorString(&FileNames);
TRI_DestroyVector(&FileDescriptors);
TRI_WriteUnlockReadWriteLock(&FileNamesLock);
}

View File

@ -1770,6 +1770,8 @@ void TRI_InitialiseLogging (bool threaded) {
////////////////////////////////////////////////////////////////////////////////
bool TRI_ShutdownLogging () {
size_t i, j;
if (! Initialised) {
return ThreadedLogging;
}
@ -1798,6 +1800,20 @@ bool TRI_ShutdownLogging () {
TRI_UnlockSpin(&OutputPrefixLock);
// cleanup output buffers
TRI_LockMutex(&BufferLock);
for (i = 0; i < OUTPUT_LOG_LEVELS; i++) {
for (j = 0; j < OUTPUT_BUFFER_SIZE; j++) {
if (BufferOutput[i][j]._text != NULL) {
TRI_FreeString(TRI_CORE_MEM_ZONE, BufferOutput[i][j]._text);
BufferOutput[i][j]._text = NULL;
}
}
}
TRI_UnlockMutex(&BufferLock);
// cleanup locks
TRI_DestroySpin(&OutputPrefixLock);
TRI_DestroySpin(&AppendersLock);

View File

@ -288,6 +288,15 @@ size_t TRI_LengthStringBuffer (TRI_string_buffer_t const * self) {
return (size_t) (self->_current - self->_buffer);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief increases length of the character buffer
////////////////////////////////////////////////////////////////////////////////
void TRI_IncreaseLengthStringBuffer (TRI_string_buffer_t * self, size_t n)
{
self->_current += n;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns true if buffer is empty
////////////////////////////////////////////////////////////////////////////////

View File

@ -164,6 +164,12 @@ char const * TRI_EndStringBuffer (TRI_string_buffer_t const * self);
size_t TRI_LengthStringBuffer (TRI_string_buffer_t const * self);
////////////////////////////////////////////////////////////////////////////////
/// @brief increases length of the character buffer
////////////////////////////////////////////////////////////////////////////////
void TRI_IncreaseLengthStringBuffer (TRI_string_buffer_t * self, size_t n);
////////////////////////////////////////////////////////////////////////////////
/// @brief returns true if buffer is empty
////////////////////////////////////////////////////////////////////////////////

View File

@ -78,7 +78,7 @@ Job::JobType Handler::type () {
/// @brief returns the queue name
////////////////////////////////////////////////////////////////////////////////
string const& Handler::queue () {
string const& Handler::queue () const {
static string standard = "STANDARD";
return standard;
}

View File

@ -144,7 +144,7 @@ namespace triagens {
/// @brief returns the queue name
////////////////////////////////////////////////////////////////////////////////
virtual string const& queue ();
virtual string const& queue () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the thread which currently dealing with the job

View File

@ -552,8 +552,7 @@ void HttpResponse::setCookie (string const& name, string const& value,
}
char const* l = StringUtils::duplicate(buffer->c_str());
buffer->clear();
free(buffer);
delete buffer;
_cookies.push_back(l);
_freeables.push_back(l);

View File

@ -67,7 +67,6 @@ SocketTask::SocketTask (TRI_socket_t socket, double keepAliveTimeout)
ownBuffer(true),
writeLength(0) {
_readBuffer = new StringBuffer(TRI_UNKNOWN_MEM_ZONE);
tmpReadBuffer = new char[READ_BLOCK_SIZE];
ConnectionStatisticsAgent::acquire();
ConnectionStatisticsAgentSetStart(this);
@ -102,8 +101,6 @@ SocketTask::~SocketTask () {
delete _readBuffer;
delete[] tmpReadBuffer;
ConnectionStatisticsAgentSetEnd(this);
ConnectionStatisticsAgent::release();
}
@ -151,12 +148,19 @@ void SocketTask::setKeepAliveTimeout (double timeout) {
bool SocketTask::fillReadBuffer (bool& closed) {
closed = false;
// reserve some memory for reading
if (_readBuffer->reserve(READ_BLOCK_SIZE) == TRI_ERROR_OUT_OF_MEMORY) {
// out of memory
LOGGER_TRACE("out of memory");
int nr = TRI_READ_SOCKET(_commSocket, tmpReadBuffer, READ_BLOCK_SIZE, 0);
return false;
}
int nr = TRI_READ_SOCKET(_commSocket, _readBuffer->end(), READ_BLOCK_SIZE, 0);
if (nr > 0) {
_readBuffer->appendText(tmpReadBuffer, nr);
_readBuffer->increaseLength(nr);
return true;
}
else if (nr == 0) {

View File

@ -374,12 +374,6 @@ namespace triagens {
TRI_tid_t tid;
////////////////////////////////////////////////////////////////////////////////
/// @brief temporary static buffer for read requests
////////////////////////////////////////////////////////////////////////////////
char * tmpReadBuffer;
};
}
}

View File

@ -231,9 +231,13 @@ bool ClientConnection::readClientConnection (StringBuffer& stringBuffer) {
assert(_socket.fileHandle > 0);
do {
char buffer[READBUFFER_SIZE];
// reserve some memory for reading
if (stringBuffer.reserve(READBUFFER_SIZE) == TRI_ERROR_OUT_OF_MEMORY) {
// out of memory
return false;
}
int lenRead = TRI_READ_SOCKET(_socket, buffer, READBUFFER_SIZE - 1, 0);
int lenRead = TRI_READ_SOCKET(_socket, stringBuffer.end(), READBUFFER_SIZE - 1, 0);
if (lenRead == -1) {
// error occurred
@ -245,7 +249,7 @@ bool ClientConnection::readClientConnection (StringBuffer& stringBuffer) {
break;
}
stringBuffer.appendText(buffer, lenRead);
stringBuffer.increaseLength(lenRead);
}
while (readable());

View File

@ -227,7 +227,7 @@ bool SslClientConnection::writeClientConnection (void* buffer, size_t length, si
case SSL_ERROR_WANT_CONNECT:
case SSL_ERROR_SYSCALL:
default: {
/* fallthrough */
/* fall through */
}
}
@ -244,13 +244,17 @@ bool SslClientConnection::readClientConnection (StringBuffer& stringBuffer) {
}
do {
char buffer[READBUFFER_SIZE];
// reserve some memory for reading
if (stringBuffer.reserve(READBUFFER_SIZE) == TRI_ERROR_OUT_OF_MEMORY) {
// out of memory
return false;
}
int lenRead = SSL_read(_ssl, buffer, READBUFFER_SIZE - 1);
int lenRead = SSL_read(_ssl, stringBuffer.end(), READBUFFER_SIZE - 1);
switch (SSL_get_error(_ssl, lenRead)) {
case SSL_ERROR_NONE:
stringBuffer.appendText(buffer, lenRead);
stringBuffer.increaseLength(lenRead);
break;
case SSL_ERROR_ZERO_RETURN: