Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Menunjukkan apakah IIS akan menutup permintaan yang saat ini tertunda dengan baik.
Sintaks
virtual BOOL DrainRequestsGracefully(
VOID
) const = 0;
Parameter
Metode ini tidak memerlukan parameter.
Tampilkan Nilai
true jika IIS akan menutup permintaan saat ini dengan baik; jika tidak, false.
Keterangan
Metode ini DrainRequestsGracefully mengambil informasi tentang bagaimana IIS akan menutup permintaan yang tertunda ketika proses pekerja dimatikan. Misalnya, jika IIS dimulai ulang, DrainRequestsGracefully metode akan kembali false karena semua permintaan yang tertunda akan dihentikan. Namun, jika kumpulan aplikasi didaur ulang, DrainRequestsGracefully metode akan kembali true karena semua permintaan yang tertunda pada proses pekerja yang dimatikan akan ditutup dengan baik.
Contoh
Contoh kode berikut menunjukkan cara membuat modul HTTP yang melakukan tugas berikut:
Mendaftar untuk pemberitahuan GL_STOP_LISTENING .
Membuat kelas CGlobalModule yang berisi metode OnGlobalStopListening . Metode ini melakukan tugas-tugas berikut:
Mengambil status yang akan digunakan IIS untuk menutup permintaan saat ini dengan menggunakan
DrainRequestsGracefullymetode .Memformat string yang berisi informasi status.
Menulis string sebagai peristiwa ke log aplikasi Pemampil Peristiwa.
CGlobalModuleMenghapus kelas dari memori lalu keluar.
#define _WINSOCKAPI_
#include <windows.h>
#include <sal.h>
#include <httpserv.h>
// Create the module's global class.
class MyGlobalModule : public CGlobalModule
{
public:
// Process a GL_STOP_LISTENING notification.
GLOBAL_NOTIFICATION_STATUS
OnGlobalStopListening(
IN IGlobalStopListeningProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Create a string buffer.
char szBuffer[256] = "";
// Retrieve the Boolean value and format the string.
sprintf_s(szBuffer,255,"Drain Requests Gracefully: %s",
(TRUE==pProvider->DrainRequestsGracefully())?"Yes":"No");
// Write the string to the event viewer.
WriteEventViewerLog(szBuffer);
// Continue processing.
return GL_NOTIFICATION_CONTINUE;
}
VOID Terminate()
{
// Remove the class from memory.
delete this;
}
MyGlobalModule()
{
// Open a handle to the Event Viewer.
m_hEventLog = RegisterEventSource( NULL,"IISADMIN" );
}
~MyGlobalModule()
{
// Test whether the handle for the Event Viewer is open.
if (NULL != m_hEventLog)
{
// Close the handle to the Event Viewer.
DeregisterEventSource( m_hEventLog );
m_hEventLog = NULL;
}
}
private:
// Create a handle for the event viewer.
HANDLE m_hEventLog;
// Define a method that writes to the Event Viewer.
BOOL WriteEventViewerLog(LPCSTR szNotification)
{
// Test whether the handle for the Event Viewer is open.
if (NULL != m_hEventLog)
{
// Write any strings to the Event Viewer and return.
return ReportEvent(
m_hEventLog, EVENTLOG_INFORMATION_TYPE, 0, 0,
NULL, 1, 0, &szNotification, NULL );
}
return FALSE;
}
};
// Create the module's exported registration function.
HRESULT
__stdcall
RegisterModule(
DWORD dwServerVersion,
IHttpModuleRegistrationInfo * pModuleInfo,
IHttpServer * pGlobalInfo
)
{
UNREFERENCED_PARAMETER( dwServerVersion );
UNREFERENCED_PARAMETER( pGlobalInfo );
// Create an instance of the global module class.
MyGlobalModule * pGlobalModule = new MyGlobalModule;
// Test for an error.
if (NULL == pGlobalModule)
{
return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
}
// Set the global notifications and exit.
return pModuleInfo->SetGlobalNotifications(
pGlobalModule, GL_STOP_LISTENING );
}
Modul Anda harus mengekspor fungsi RegisterModule . Anda dapat mengekspor fungsi ini dengan membuat file definisi modul (.def) untuk proyek Anda, atau Anda dapat mengkompilasi modul dengan menggunakan sakelar /EXPORT:RegisterModule . Untuk informasi selengkapnya, lihat Panduan: Membuat Modul HTTP Request-Level Dengan Menggunakan Kode Asli.
Anda dapat secara opsional mengkompilasi kode dengan menggunakan __stdcall (/Gz) konvensi panggilan alih-alih secara eksplisit mendeklarasikan konvensi panggilan untuk setiap fungsi.
Persyaratan
| Jenis | Deskripsi |
|---|---|
| Klien | - IIS 7.0 di Windows Vista - IIS 7.5 di Windows 7 - IIS 8.0 di Windows 8 - IIS 10.0 pada Windows 10 |
| Server | - IIS 7.0 di Windows Server 2008 - IIS 7.5 di Windows Server 2008 R2 - IIS 8.0 di Windows Server 2012 - IIS 8.5 di Windows Server 2012 R2 - IIS 10.0 di Windows Server 2016 |
| Produk | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - IIS Express 7.5, IIS Express 8.0, IIS Express 10.0 |
| Header | Httpserv.h |