Project

General

Profile

Bug #9106 » 0002-TEST-ONLY.-Force-webrequest-leak.patch

Bruce Toll, 09/24/2021 07:49 PM

View differences:

src/http/HTTPRequest.C
255 255
  return p->request().url_params;
256 256
}
257 257

  
258
void HTTPRequest::setWebSession(WebSessionPtr webSession)
259
{
260
  reply_->setWebSession(webSession);
261
}
262

  
258 263
} // namespace server
259 264
} // namespace http
src/http/HTTPRequest.h
56 56
  bool isSynchronous() const;
57 57
  virtual Wt::WSslInfo *sslInfo() const override;
58 58
  virtual const std::vector<std::pair<std::string, std::string> > &urlParams() const override;
59
  virtual void setWebSession(WebSessionPtr webSession) override;
59 60

  
60 61
private:
61 62
  WtReplyPtr reply_;
src/http/WtReply.C
8 8
#include "WtReply.h"
9 9
#include "StockReply.h"
10 10
#include "HTTPRequest.h"
11
#include "WebSession.h"
11 12
#include "WebController.h"
12 13
#include "Server.h"
13 14
#include "WebUtils.h"
......
432 433
    return;
433 434
  }
434 435

  
436
  if (webSessionLock_) {
437
    LOG_DEBUG("WtReply::writeDone webSessionLock_ about to set null, currently: " << webSessionLock_.get());
438
    webSessionLock_ = nullptr;
439
  }
440

  
435 441
  LOG_DEBUG("writeDone() success:" << success << ", sent: " << sending_);
436 442
  out_buf_.consume(sending_);
437 443
  sending_ = 0;
......
448 454
{
449 455
  LOG_DEBUG("WtReply::send(): " << sending_);
450 456

  
457
  webSessionLock_ = webSessionWeakPtr_.lock();
458
  LOG_DEBUG("WtReply::send set webSessionLock_ to: " << webSessionLock_.get());
459

  
451 460
  fetchMoreDataCallback_ = callBack;
452 461

  
453 462
  if (sending_ != 0) {
......
662 671
}
663 672

  
664 673

  
674
void WtReply::setWebSession(Wt::WebRequest::WebSessionPtr webSession)
675
{
676
    webSessionWeakPtr_ = webSession;
677
}
678

  
679

  
665 680
#ifdef WTHTTP_WITH_ZLIB
666 681

  
667 682
bool WtReply::initDeflate() 
src/http/WtReply.h
15 15
#include "Reply.h"
16 16
#include "../web/Configuration.h"
17 17
#include "../web/WebRequest.h"
18
#include "../web/WebSession.h"
18 19

  
19 20
#ifdef WTHTTP_WITH_ZLIB
20 21
#include <zlib.h>
......
59 60
	    bool responseComplete);
60 61
  void readWebSocketMessage(const Wt::WebRequest::ReadCallback& callBack);
61 62
  bool readAvailable();
63
  void setWebSession(Wt::WebRequest::WebSessionPtr webSession);
62 64

  
63 65
  std::istream& in() { return *in_; }
64 66
  std::ostream& out() { return out_; }
......
106 108
  bool initDeflate();
107 109

  
108 110
  z_stream zOutState_;
111
  std::weak_ptr<Wt::WebSession> webSessionWeakPtr_;
112
  Wt::WebRequest::WebSessionPtr webSessionLock_;
109 113
#endif
110 114
};
111 115

  
src/web/WebRequest.C
337 337
  return urlParams_;
338 338
}
339 339

  
340
void WebRequest::setWebSession(WebSessionPtr webSession)
341
{
342
  throw WException("should not get here");
343
}
344

  
340 345
}
src/web/WebRequest.h
48 48
  typedef std::function<void(WebReadEvent)> ReadCallback;
49 49
  typedef std::function<void(void)> DisconnectCallback;
50 50

  
51
  typedef std::shared_ptr<Wt::WebSession> WebSessionPtr;
52

  
51 53
  /*
52 54
   * Signal that the response should be flushed.
53 55
   *
......
197 199
  virtual WSslInfo *sslInfo() const = 0;
198 200

  
199 201
  virtual const std::vector<std::pair<std::string, std::string> >& urlParams() const;
202
  virtual void setWebSession(WebSessionPtr webSession);
200 203

  
201 204
protected:
202 205
  const EntryPoint *entryPoint_;
src/web/WebSession.C
17 17
#include "Wt/WServer.h"
18 18
#include "Wt/WTimerWidget.h"
19 19
#include "Wt/Http/Request.h"
20
#include "http/HTTPRequest.h"
20 21

  
21 22
#include "CgiParser.h"
22 23
#include "Configuration.h"
......
252 253
  }
253 254

  
254 255
  if (webSocket_) {
256
    LOG_DEBUG("~WebSession: before webSocket_ flush/null");
255 257
    webSocket_->flush();
256 258
    webSocket_ = nullptr;
259
    LOG_DEBUG("~WebSession: after webSocket_ flush/null");
257 260
  }
258 261

  
259 262
  if (deferredResponse_) {
......
707 710
void WebSession::kill()
708 711
{
709 712
  state_ = State::Dead;
713
  if (webSocket_)
714
    webSocket_->setWebSession(shared_from_this());
710 715

  
711 716
  /*
712 717
   * Unlock the recursive eventloop that may be pending.
713
- 
(2-2/4)