🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #5498

Re: 'Out of memory' exception for a IdTCPServer

#5498
From: Remy Lebeau (TeamB)
Date: Thu, 12 Aug 2004 21:38
67 lines
3081 bytes
"Drew" <aemsley@brightwell.org.uk> wrote in message
news:411bdf12$1@newsgroups.borland.com...

>     RtrServer->Active = true;
>
>     RtrServer->CommandHandlersEnabled = true;

You should set up the command handlers before you activate the server, not
afterwards.

>     RtrServer->CommandHandlers->Add();
>     RtrServer->CommandHandlers->Items[0]->Command = readRtrParams;
>     RtrServer->CommandHandlers->Items[0]->OnCommand =
> RtrServerReadRtrParams;

You should use the return value of Add() instead of indexing the Items[]
collection over and over:

    TIdCommandHandler *Handler = RtrServer->CommandHandlers->Add();
    Handler->Command = readRtrParams;
    Handler->->OnCommand = RtrServerReadRtrParams;

> void __fastcall RTRSvrThread::RtrServerDisconnect(TIdPeerThread *AThread)
> {
>     Log(0, "Rtr Server disconnected");
> }

What exactly does Log() do?  Is its code thread-safe?

> The error log shows the following:
>
>     19:59:43.56: Rtr Server exception: Out of memory
>     19:59:43.56: Rtr server disconnected

That suggests that one of your command handlers is probably where the
exception is being thrown.  Can you please show the actual handler code?

>                                char* sendBuffer;
>
>                                sendBuffer = new char[sizeof(SiteData_t)];
>
>                                memcpy(sendBuffer, site,
sizeof(SiteData_t));
>
>                                Log(2, "Sending info buffer to DBM");
>                                DbmClient->WriteBuffer(sendBuffer,
> sizeof(SiteData_t));
>
>                                delete[] sendBuffer;

Why allocate a new buffer?  Just send the original data directly:

    DbmClient->WriteBuffer(site, sizeof(SiteData_t));


> On the client side, the error log shows:
>
>     19:59:43.56: Sending updateHilltopInfo message to DBM
>     19:59:43.56: Read of ACK from DBM failed
>     19:59:43.56: Exception gnerated = Connection Closed Gracefully.

That is to be expected since the server disconnected the client when the
exception occured.


Gambit
Technical Details
Message-ID: <411be31c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <411b903e@newsgroups.borland.com> <411ba247$1@newsgroups.borland.com> <411bdf12$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,56db4bd962ab0eb3
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <411b903e@newsgroups.borland.com> <411ba247$1@newsgroups.borland.com> <411bdf12$1@newsgroups.borland.com>
Subject: Re: 'Out of memory' exception for a IdTCPServer
Date: Thu, 12 Aug 2004 14:38:19 -0700
Lines: 69
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <411be31c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1092346652 68.69.17.41 (12 Aug 2004 14:37:32 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail