[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] bug in webtraf.cc
I've incorporated Felix's patch into the webtraf patch for ns-2.1b6
online. This'll also appear in tomorrow's snapshot.
Thanks a lot.
- Haobo
On Tue, 11 Apr 2000, Felix Hernandez Campos wrote:
> Hi,
>
> I found a bug in webtraf.cc. The code in the current snapshot only uses one
> object per page. The problem is that WebPage instances do not reschedule more
> object requests after the first one is completed. It looks like something got
> broken by the last patch.
>
> I have fixed it by modifying WebPage::start() and WebPage::handle() in the
> following way:
>
> inline void start() {
> expire();
> sched(sess_->interObj()->value()); // <---- NEW
> curObj_++; // <---- NEW
> }
>
> virtual void handle(Event *e) {
> // XXX Note when curObj_ == nObj_, we still schedule the timer
> // once, but we do not actually send out requests. This extra
> // schedule is only meant to be a hint to wait for the last
> // request to finish, then we will ask our parent to delete
> // this page.
>
> if (curObj_ < nObj_)
> TimerHandler::handle(e);
>
> // If this is not the last object, schedule the next one.
> // Otherwise stop and tell session to delete me.
>
> if (curObj_ >= nObj_) { // <---- MODIFIED
> sess_->donePage((void*)this);
> } else {
> curObj_++;
> sched(sess_->interObj()->value());
> }
> }
>
> I also modified donePage() and expire() in WebTrafSession, adding an extra
> schedule to get rid of deletion problems:
>
> void WebTrafSession::donePage(void* ClntData)
> {
> delete (WebPage*)ClntData;
> // If all pages are done, tell my parent to delete myself
>
> // extra schedule
> if (++donePage_ > nPage_) // <--- MODIFIED
> mgr_->doneSession(id_);
> }
>
> // Launch the current page
> void WebTrafSession::expire(Event *)
> {
>
> if (donePage_ < nPage_) { // <---- NEW
>
> // Pick destination for this page
> Node* dst = mgr_->pickdst();
> // Make sure page size is not 0!
> WebPage* pg = new WebPage(LASTPAGE_++, this,
> (int)ceil(rvPageSize_->value()), dst);
> #if 0
> printf("Session %d starting page %d, curpage %d \n",
> id_, LASTPAGE_-1, curPage_);
> #endif
> pg->start();
> } else { // <---- NEW
> donePage((void*)this); // <---- NEW
> } // <---- NEW
>
> }
>
> The generated traffic looks correct.
>
> -- Felix Hernandez
>
>