Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | new THttpServerGeneric.OnHttpThreadTerminate event, available to clean-up any process in the thread context, when it is terminated (to call e.g. TSQLDBConnectionPropertiesThreadSafe.EndCurrentThread in order to call CoUnInitialize from thread in which CoInitialize was initialy made) - see http://synopse.info/fossil/tktview?name=213544b2f5 |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
b2e16aae7d48bc702320dc35a6e527f2 |
User & Date: | G018869 2012-04-25 14:30:15 |
2012-04-25
| ||
14:33 | • Fixed ticket [213544b2f5]: SynOleDB CoUninit assert remove plus 3 other changes artifact: e9a33acade user: ab | |
2012-04-28
| ||
07:54 | added RecordManySourceProp / RecordManyDestProp / RecordManySourceClass / RecordManyDestClass to the TSQLRecordProperties check-in: f7a31b4586 user: User tags: trunk | |
2012-04-25
| ||
14:30 | new THttpServerGeneric.OnHttpThreadTerminate event, available to clean-up any process in the thread context, when it is terminated (to call e.g. TSQLDBConnectionPropertiesThreadSafe.EndCurrentThread in order to call CoUnInitialize from thread in which CoInitialize was initialy made) - see http://synopse.info/fossil/tktview?name=213544b2f5 check-in: b2e16aae7d user: G018869 tags: trunk | |
2012-04-20
| ||
17:08 | added article about WCF and mORMot SOA implementations check-in: 3870d7cf0f user: G018869 tags: trunk | |
Changes to SynCrtSock.pas.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 ... 554 555 556 557 558 559 560 561 562 563 564 565 566 567 ... 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 .... 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 .... 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 |
- unit now tested with Delphi XE2 (32 Bit) - fixed issue in HTTP_RESPONSE.SetHeaders Version 1.16 - fixed issue in case of wrong void parameter e.g. in THttpApiServer.AddUrl - circumvent some bugs of Delphi XE2 background compiler (main compiler is OK) - added 'RemoteIP: 127.0.0.1' to the retrieved HTTP headers } interface { $define DEBUG2} { $define DEBUG23} ................................................................................ protected /// optional event handler for the virtual Request method fOnRequest: TOnHttpServerRequest; /// list of all registered compression algorithms fCompress: THttpSocketCompressRecDynArray; /// set by RegisterCompress method fCompressAcceptEncoding: TSockData; public /// override this function to customize your http server // - InURL/InMethod/InContent properties are input parameters // - OutContent/OutContentType/OutCustomHeader are output parameters // - result of the function is the HTTP error code (200 if OK, e.g.) // - OutCustomHeader will handle Content-Type/Location // - if OutContentType is HTTP_RESP_STATICFILE (i.e. '!STATICFILE'), ................................................................................ function Request(const InURL, InMethod, InHeaders, InContent, InContentType: TSockData; out OutContent, OutContentType, OutCustomHeader: TSockData): cardinal; virtual; /// will register a compression algorithm // - used e.g. to compress on the fly the data, with standard gzip/deflate // or custom (synlzo/synlz) protocols // - the first registered algorithm will be the prefered one for compression procedure RegisterCompress(aFunction: THttpSocketCompress); virtual; /// the event handled called by the default implementation of the // virtual Request method // - warning: this process must be thread-safe (can be called by several // threads simultaneously) property OnRequest: TOnHttpServerRequest read fOnRequest write fOnRequest; end; {/ HTTP server using fast http.sys kernel-mode server - The HTTP Server API enables applications to communicate over HTTP without using Microsoft Internet Information Server (IIS). Applications can register to receive HTTP requests for particular URLs, receive HTTP requests, and send HTTP responses. The HTTP Server API includes SSL support so that applications ................................................................................ constructor THttpApiServer.CreateClone(From: THttpApiServer); begin inherited Create(false); fReqQueue := From.fReqQueue; fOnRequest := From.OnRequest; fCompress := From.fCompress; fCompressAcceptEncoding := From.fCompressAcceptEncoding; end; destructor THttpApiServer.Destroy; var i: Integer; begin if fClones<>nil then begin // fClones=nil for clone threads ................................................................................ OutCustomHeader: TSockData): cardinal; begin if Assigned(OnRequest) then result := OnRequest(InURL,InMethod,InHeaders,InContent,InContentType, OutContent,OutContentType,OutCustomHeader) else result := 404; // 404 NOT FOUND end; {$ifdef USEWININET} { TWinHttpAPI } constructor TWinHttpAPI.Create(const aServer, aPort: AnsiString; |
> > > > > > > | > > > > > > > > > > > > > > > > > > |
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 ... 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 ... 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 .... 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 .... 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 |
- unit now tested with Delphi XE2 (32 Bit) - fixed issue in HTTP_RESPONSE.SetHeaders Version 1.16 - fixed issue in case of wrong void parameter e.g. in THttpApiServer.AddUrl - circumvent some bugs of Delphi XE2 background compiler (main compiler is OK) - added 'RemoteIP: 127.0.0.1' to the retrieved HTTP headers - new THttpServerGeneric.OnHttpThreadTerminate event, available to clean-up any process in the thread context, when it is terminated (to call e.g. TSQLDBConnectionPropertiesThreadSafe.EndCurrentThread in order to call CoUnInitialize from thread in which CoInitialize was initialy made) - see http://synopse.info/fossil/tktview?name=213544b2f5 } interface { $define DEBUG2} { $define DEBUG23} ................................................................................ protected /// optional event handler for the virtual Request method fOnRequest: TOnHttpServerRequest; /// list of all registered compression algorithms fCompress: THttpSocketCompressRecDynArray; /// set by RegisterCompress method fCompressAcceptEncoding: TSockData; fOnHttpThreadTerminate: TNotifyEvent; procedure DoTerminate; override; public /// override this function to customize your http server // - InURL/InMethod/InContent properties are input parameters // - OutContent/OutContentType/OutCustomHeader are output parameters // - result of the function is the HTTP error code (200 if OK, e.g.) // - OutCustomHeader will handle Content-Type/Location // - if OutContentType is HTTP_RESP_STATICFILE (i.e. '!STATICFILE'), ................................................................................ function Request(const InURL, InMethod, InHeaders, InContent, InContentType: TSockData; out OutContent, OutContentType, OutCustomHeader: TSockData): cardinal; virtual; /// will register a compression algorithm // - used e.g. to compress on the fly the data, with standard gzip/deflate // or custom (synlzo/synlz) protocols // - the first registered algorithm will be the prefered one for compression procedure RegisterCompress(aFunction: THttpSocketCompress); virtual; /// event handler called by the default implementation of the // virtual Request method // - warning: this process must be thread-safe (can be called by several // threads simultaneously) property OnRequest: TOnHttpServerRequest read fOnRequest write fOnRequest; /// event handler called when the Thread is terminating, in the thread context // - the TThread.OnTerminate event will be called within a Synchronize() // wrapper, so it won't fit our purpose // - to be used e.g. to call CoUnInitialize from thread in which CoInitialize // was made, for instance via a method defined as such: // ! procedure TMyServer.OnHttpThreadTerminate(Sender: TObject); // ! begin // TSQLDBConnectionPropertiesThreadSafe // ! fMyConnectionProps.EndCurrentThread; // ! end; property OnHttpThreadTerminate: TNotifyEvent read fOnHttpThreadTerminate write fOnHttpThreadTerminate; end; {/ HTTP server using fast http.sys kernel-mode server - The HTTP Server API enables applications to communicate over HTTP without using Microsoft Internet Information Server (IIS). Applications can register to receive HTTP requests for particular URLs, receive HTTP requests, and send HTTP responses. The HTTP Server API includes SSL support so that applications ................................................................................ constructor THttpApiServer.CreateClone(From: THttpApiServer); begin inherited Create(false); fReqQueue := From.fReqQueue; fOnRequest := From.OnRequest; fCompress := From.fCompress; fOnHttpThreadTerminate := From.fOnHttpThreadTerminate; fCompressAcceptEncoding := From.fCompressAcceptEncoding; end; destructor THttpApiServer.Destroy; var i: Integer; begin if fClones<>nil then begin // fClones=nil for clone threads ................................................................................ OutCustomHeader: TSockData): cardinal; begin if Assigned(OnRequest) then result := OnRequest(InURL,InMethod,InHeaders,InContent,InContentType, OutContent,OutContentType,OutCustomHeader) else result := 404; // 404 NOT FOUND end; procedure THttpServerGeneric.DoTerminate; begin if Assigned(fOnHttpThreadTerminate) then fOnHttpThreadTerminate(self); inherited DoTerminate; end; {$ifdef USEWININET} { TWinHttpAPI } constructor TWinHttpAPI.Create(const aServer, aPort: AnsiString; |
Changes to SynDB.pas.
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
// - warning: no connection shall be still be used on the background, or // some unexpected border effects may occur procedure ClearConnectionPool; override; /// you can call this method just before a thread is finished to ensure // that the associated Connection will be released // - could be used e.g. in a try...finally block inside a TThread.Execute // overriden method procedure EndCurrentThread; end; /// a structure used to store a standard binding parameter // - you can use your own internal representation of parameters // (TOleDBStatement use its own TOleDBStatementParam type), but // this type can be used to implement a generic parameter |
> > > > > > |
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
// - warning: no connection shall be still be used on the background, or // some unexpected border effects may occur procedure ClearConnectionPool; override; /// you can call this method just before a thread is finished to ensure // that the associated Connection will be released // - could be used e.g. in a try...finally block inside a TThread.Execute // overriden method // - could be used e.g. to call CoUnInitialize from thread in which // CoInitialize was made, for instance via a method defined as such: // ! procedure TMyServer.OnHttpThreadTerminate(Sender: TObject); // ! begin // ! fMyConnectionProps.EndCurrentThread; // ! end; procedure EndCurrentThread; end; /// a structure used to store a standard binding parameter // - you can use your own internal representation of parameters // (TOleDBStatement use its own TOleDBStatementParam type), but // this type can be used to implement a generic parameter |
Changes to SynOleDB.pas.
1 2 3 4 5 6 7 8 9 10 .. 64 65 66 67 68 69 70 71 72 73 74 75 76 77 .... 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 |
/// fast OleDB direct access classes // - this unit is a part of the freeware Synopse mORMot framework, // licensed under a MPL/GPL/LGPL tri-license; version 1.15 unit SynOleDB; { This file is part of Synopse mORMot framework. Synopse mORMot framework. Copyright (C) 2012 Arnaud Bouchez Synopse Informatique - http://synopse.info ................................................................................ - made the code compatible with Delphi 5 - TOleDBStatement class now follows the prepared statement pattern introduced with its parent TSQLDBStatement - now able to retrieve table names and column information from OleDB metadata including GetTableNames, GetFields, GetFieldDefinitions and GetForeignKey methods - able to use faster direct SQL retrieval (e.g. for Oracle / MS SQL) } {$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER interface uses ................................................................................ inc(OleDBCoInitialized); if OleDBCoInitialized=1 then CoInitialize(nil); end; procedure CoUninit; begin assert(OleDBCoinitialized>0); dec(OleDBCoinitialized); if OleDBCoinitialized=0 then CoUninitialize; end; procedure TOleDBConnection.Connect; var DataInitialize : IDataInitialize; |
| > > > > > | > > |
1 2 3 4 5 6 7 8 9 10 .. 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 .... 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 |
/// fast OleDB direct access classes // - this unit is a part of the freeware Synopse mORMot framework, // licensed under a MPL/GPL/LGPL tri-license; version 1.16 unit SynOleDB; { This file is part of Synopse mORMot framework. Synopse mORMot framework. Copyright (C) 2012 Arnaud Bouchez Synopse Informatique - http://synopse.info ................................................................................ - made the code compatible with Delphi 5 - TOleDBStatement class now follows the prepared statement pattern introduced with its parent TSQLDBStatement - now able to retrieve table names and column information from OleDB metadata including GetTableNames, GetFields, GetFieldDefinitions and GetForeignKey methods - able to use faster direct SQL retrieval (e.g. for Oracle / MS SQL) Version 1.16 - add some reference to http://synopse.info/fossil/tktview?name=213544b2f5 in case of wrong implementation of multi-thread connection (within the THttpServerGeneric mORMot server, for instance) } {$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER interface uses ................................................................................ inc(OleDBCoInitialized); if OleDBCoInitialized=1 then CoInitialize(nil); end; procedure CoUninit; begin assert(OleDBCoinitialized>0,'You should call TOleDBConnection.Free from the same '+ 'thread which called its Create: i.e. call MyProps.EndCurrentThread from an '+ 'THttpServerGeneric.OnHttpThreadTerminate event - see ticket 213544b2f5'); dec(OleDBCoinitialized); if OleDBCoinitialized=0 then CoUninitialize; end; procedure TOleDBConnection.Connect; var DataInitialize : IDataInitialize; |