Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1011 lines
22 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1994-1997 **/
  4. /**********************************************************************/
  5. /*
  6. atq.h
  7. This module contains async thread queue (atq) for async IO and thread
  8. pool sharing among various services.
  9. Brief Description of ATQ:
  10. For description, please see iis\spec\isatq.doc
  11. */
  12. #ifndef _ATQ_H_
  13. #define _ATQ_H_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. // Include Standard headers
  18. # include <nt.h>
  19. # include <ntrtl.h>
  20. # include <nturtl.h>
  21. # include <windows.h>
  22. # include <winsock2.h>
  23. # include <mswsock.h>
  24. #ifndef dllexp
  25. #define dllexp __declspec( dllexport )
  26. #endif
  27. /*++
  28. ATQ API Overview:
  29. Global per module:
  30. AtqInitialize()
  31. AtqTerminate()
  32. AtqGetInfo()
  33. AtqSetInfo()
  34. ATQ Endpoint functions:
  35. AtqCreateEndpoint()
  36. AtqStartEndpoint()
  37. AtqEndpointGetInfo()
  38. AtqEndpointSetInfo()
  39. AtqStopCloseEndpoint()
  40. AtqCloseCloseEndpoint()
  41. AtqStopAndCloseEndpoint() <-- soon to be killed
  42. Per ATQ Context Functions:
  43. AtqAddAsyncHandle() <-- for non AcceptEx() sockets
  44. AtqGetAcceptExAddrs() <-- for AcceptEx() sockets
  45. AtqContextSetInfo()
  46. AtqCloseFileHandle()
  47. AtqCloseSocket()
  48. AtqFreeContext()
  49. Bandwidth Throttler Functions:
  50. AtqCreateBandwidthInfo()
  51. AtqFreeBandwidthInfo()
  52. AtqBandwidthSetInfo()
  53. AtqBandwidthGetInfo()
  54. IO Functions:
  55. AtqReadFile()
  56. AtqWriteFile()
  57. AtqReadSocket()
  58. AtqWriteSocket()
  59. AtqTransmitFile()
  60. AtqTransmitFileAndRecv()
  61. AtqSendAndRecv()
  62. Utility Functions:
  63. AtqCreateFile()
  64. AtqCreateFileW()
  65. AtqOplockAcknowledge()
  66. AtqSpudInitialized()
  67. AtqReadDirChanges()
  68. AtqPostCompletionStatus()
  69. --*/
  70. /*----------------------------------------------------------
  71. Registry Parameters used by ATQ during AtqInitialize()
  72. ATQ loads some of the parameters from
  73. HKLM\System\CurrentControlSet\Services\InetInfo\Parameters
  74. Most of these parameters are for INTERNAL ANALYSIS and
  75. development/testing. Setup should not install values
  76. for the same. Setup can include values for items marked SETUP.
  77. ------------------------------------------------------------*/
  78. // Names
  79. #define ATQ_REG_PER_PROCESSOR_ATQ_THREADS TEXT("MaxPoolThreads")
  80. #define ATQ_REG_POOL_THREAD_LIMIT TEXT("PoolThreadLimit") // SETUP
  81. #define ATQ_REG_PER_PROCESSOR_CONCURRENCY TEXT("MaxConcurrency")
  82. #define ATQ_REG_THREAD_TIMEOUT TEXT("ThreadTimeout")
  83. #define ATQ_REG_USE_ACCEPTEX TEXT("UseAcceptEx")
  84. #define ATQ_REG_MIN_KB_SEC TEXT("MinFileKbSec") // SETUP
  85. #define ATQ_REG_LISTEN_BACKLOG TEXT("ListenBacklog") // SETUP
  86. // Default Values
  87. #define ATQ_REG_DEF_PER_PROCESSOR_ATQ_THREADS (4)
  88. #define ATQ_REG_DEF_PER_PROCESSOR_CONCURRENCY (0)
  89. // special value of 0 means that system will determine this dynamically.
  90. //
  91. // thread limit settings
  92. //
  93. #define ATQ_REG_MIN_POOL_THREAD_LIMIT (64)
  94. #define ATQ_REG_DEF_POOL_THREAD_LIMIT (128)
  95. #define ATQ_REG_MAX_POOL_THREAD_LIMIT (256)
  96. //
  97. // How often to check for thread progress.
  98. //
  99. #define ATQ_THREAD_MONITOR_PERIOD (2*60) // 2 Minutes
  100. //
  101. // How many IO's a temp thread should handle before
  102. // exiting
  103. //
  104. #define ATQ_TEMP_THREAD_IO_COUNT (100)
  105. //
  106. // THREAD_TIMEOUTs are high to prevent async ios from being cancelled
  107. // when the thread goes away.
  108. //
  109. #define ATQ_REG_DEF_THREAD_TIMEOUT (12*60*60) // 12 hours
  110. #define ATQ_REG_DEF_USE_ACCEPTEX (TRUE)
  111. #define ATQ_REG_DEF_MIN_KB_SEC (1000) // 1000 bytes
  112. #define ATQ_REG_DEF_LISTEN_BACKLOG (25)
  113. //
  114. // fake xmit file buffer size
  115. //
  116. #define ATQ_REG_DEF_NONTF_BUFFER_SIZE (4096)
  117. /*----------------------------------------------------------
  118. Global Functions of ATQ module
  119. -----------------------------------------------------------*/
  120. // Flags for AtqInitialize()
  121. # define ATQ_INIT_SPUD_FLAG (0x00000001)
  122. BOOL
  123. AtqInitialize(
  124. IN DWORD dwFlags
  125. );
  126. BOOL
  127. AtqTerminate(
  128. VOID
  129. );
  130. /*
  131. * Sets various context information in Atq Module for global modifications
  132. *
  133. *
  134. * Bandwidth Throttle: Sets the throttle level in Bytes/Second.
  135. * If INFINITE, then it is assumed that
  136. * there is no throttle value (default)
  137. *
  138. * Max Pool Threads: Sets the maximum number of pool threads Atq will allow
  139. * to be created per processor
  140. *
  141. * MaxConcurrency: tells how many threads to permit per processor
  142. *
  143. * Thread Timeout: Indicates how long a thread should be kep alive
  144. * waiting on GetQueuedCompletionStatus() before commiting suicide
  145. * (in seconds)
  146. *
  147. * Inc/Dec max pool threads: If a server will be doing extended processing
  148. * in an ATQ pool thread, they should increase the max pool threads
  149. * while the extended processing is occurring. This prevents starvation
  150. * of other requests
  151. *
  152. * AtqMinKbSec: set the assumed minimum KB per second for AtqTransmitFile()
  153. * This value is used in calculating the timeout for file transfer
  154. * operation
  155. *
  156. */
  157. typedef enum _ATQ_INFO {
  158. AtqBandwidthThrottle = 0,
  159. AtqExitThreadCallback,
  160. AtqMaxPoolThreads, // per processor values
  161. AtqMaxConcurrency, // per processor concurrency value
  162. AtqThreadTimeout,
  163. AtqUseAcceptEx, // Use AcceptEx if available
  164. AtqIncMaxPoolThreads, // Up the max thread count
  165. AtqDecMaxPoolThreads, // Decrease the max thread count
  166. AtqMinKbSec, // Minimum assumed transfer rate for AtqTransmitFile
  167. AtqBandwidthThrottleMaxBlocked, // Max number of blocked requests
  168. AtqUpdatePerfCounterCallback,
  169. AtqMaxDGramSend // Max bytes in a single datagram send
  170. } ATQ_INFO;
  171. //
  172. // ATQ_THREAD_EXIT_CALLBACK
  173. // Type of callback function to be called when an ATQ thread exits so
  174. // that the user of ATQ may clen up thread specific data.
  175. //
  176. typedef
  177. VOID
  178. (*ATQ_THREAD_EXIT_CALLBACK) ( VOID );
  179. //
  180. // ATQ_PERF_UPDATE_CALLBACK
  181. // Type of callback function to be called when ATQ needs to update
  182. // PerfMon counters that do no reside within ATQ.
  183. //
  184. typedef
  185. VOID
  186. (*ATQ_UPDATE_PERF_CALLBACK) (
  187. IN DWORD dwStat,
  188. IN DWORD dwOperation,
  189. IN DWORD dwChange
  190. );
  191. dllexp
  192. DWORD_PTR
  193. AtqSetInfo(
  194. IN ATQ_INFO atqInfo,
  195. IN DWORD_PTR Data
  196. );
  197. dllexp
  198. DWORD_PTR
  199. AtqGetInfo(
  200. IN ATQ_INFO atqInfo
  201. );
  202. typedef struct _ATQ_STATISTICS {
  203. DWORD cAllowedRequests;
  204. DWORD cBlockedRequests;
  205. DWORD cRejectedRequests;
  206. DWORD cCurrentBlockedRequests;
  207. DWORD MeasuredBandwidth;
  208. } ATQ_STATISTICS;
  209. dllexp
  210. BOOL AtqGetStatistics( IN OUT ATQ_STATISTICS * pAtqStats);
  211. dllexp
  212. BOOL AtqClearStatistics(VOID);
  213. /*----------------------------------------------------------
  214. ATQ Endpoint functions
  215. -----------------------------------------------------------*/
  216. //
  217. // endpoint data
  218. //
  219. typedef enum _ATQ_ENDPOINT_INFO {
  220. EndpointInfoListenPort,
  221. EndpointInfoListenSocket,
  222. EndpointInfoAcceptExOutstanding,
  223. EndpointInfoConsumerType
  224. } ATQ_ENDPOINT_INFO;
  225. //
  226. // ATQ_COMPLETION
  227. // This is the routine that is called upon IO completion (on
  228. // error or success).
  229. //
  230. // Context is the context passed to AtqAddAsyncHandle
  231. // BytesWritten is the number of bytes written to the file or
  232. // bytes written to the client's buffer
  233. // CompletionStatus is the WinError completion code
  234. // lpOverLapped is the filled in overlap structure
  235. //
  236. // If the timeout thread times out an IO request, the completion routine
  237. // will be called by the timeout thread with IOCompletion FALSE and
  238. // CompletionStatus == ERROR_SEM_TIMEOUT. The IO request is *still*
  239. // outstanding in this instance. Generally it will be completed when
  240. // the file handle is closed.
  241. //
  242. typedef
  243. VOID
  244. (*ATQ_COMPLETION)(
  245. IN PVOID Context,
  246. IN DWORD BytesWritten,
  247. IN DWORD CompletionStatus, // Win32 Error code
  248. IN OVERLAPPED * lpo
  249. );
  250. //
  251. // Type of callback function to be called when a new connection is established.
  252. // This function should be defined before including conninfo.hxx
  253. //
  254. typedef
  255. VOID
  256. (*ATQ_CONNECT_CALLBACK) (
  257. IN SOCKET sNew,
  258. IN LPSOCKADDR_IN pSockAddr,
  259. IN PVOID EndpointContext,
  260. IN PVOID EndpointObject
  261. );
  262. typedef struct _ATQ_ENDPOINT_CONFIGURATION {
  263. //
  264. // Port to listen on. If 0, system will assign
  265. //
  266. USHORT ListenPort;
  267. //
  268. // Is connectionless
  269. //
  270. BOOL fDatagram;
  271. // The next two are datagram only.
  272. BOOL fReverseQueuing; // If set then winsock will drop the oldest rather
  273. // than the newest datagram buffers when winsock buffers
  274. // overflow.
  275. INT cbDatagramWSBufSize; // How much buffer space to tell winsock to reserve
  276. // for this datagram socket.
  277. //
  278. // Prevent others from using this?
  279. //
  280. BOOL fLockDownPort;
  281. //
  282. // IP address to bind to. 0 (INADDR_ANY) == wildcard.
  283. //
  284. DWORD IpAddress;
  285. DWORD cbAcceptExRecvBuffer;
  286. DWORD nAcceptExOutstanding;
  287. DWORD AcceptExTimeout;
  288. //
  289. // Callbacks
  290. //
  291. ATQ_CONNECT_CALLBACK pfnConnect;
  292. ATQ_COMPLETION pfnConnectEx;
  293. ATQ_COMPLETION pfnIoCompletion;
  294. } ATQ_ENDPOINT_CONFIGURATION, *PATQ_ENDPOINT_CONFIGURATION;
  295. dllexp
  296. PVOID
  297. AtqCreateEndpoint(
  298. IN PATQ_ENDPOINT_CONFIGURATION Configuration,
  299. IN PVOID EndpointContext
  300. );
  301. dllexp
  302. BOOL
  303. AtqStartEndpoint(
  304. IN PVOID Endpoint
  305. );
  306. dllexp
  307. DWORD_PTR
  308. AtqEndpointGetInfo(
  309. IN PVOID Endpoint,
  310. IN ATQ_ENDPOINT_INFO EndpointInfo
  311. );
  312. dllexp
  313. DWORD_PTR
  314. AtqEndpointSetInfo(
  315. IN PVOID Endpoint,
  316. IN ATQ_ENDPOINT_INFO EndpointInfo,
  317. IN DWORD_PTR dwInfo
  318. );
  319. dllexp
  320. BOOL
  321. AtqStopEndpoint(
  322. IN PVOID Endpoint
  323. );
  324. dllexp
  325. BOOL
  326. AtqCloseEndpoint(
  327. IN PVOID Endpoint
  328. );
  329. dllexp
  330. BOOL
  331. AtqStopAndCloseEndpoint(
  332. IN PVOID Endpoint,
  333. IN LPTHREAD_START_ROUTINE lpCompletion,
  334. IN PVOID lpCompletionContext
  335. );
  336. /*----------------------------------------------------------
  337. ATQ CONTEXT functions
  338. -----------------------------------------------------------*/
  339. //
  340. // This is the public portion of an ATQ Context. It should be treated
  341. // as read only
  342. //
  343. // !!! Changes made to this structure should also be made to
  344. // ATQ_CONTEXT in atqtypes.hxx !!!
  345. //
  346. typedef struct _ATQ_CONTEXT_PUBLIC {
  347. HANDLE hAsyncIO; // handle for async i/o object: socket/file
  348. OVERLAPPED Overlapped; // Overlapped structure used for IO
  349. } ATQ_CONTEXT_PUBLIC, *PATQ_CONTEXT;
  350. dllexp
  351. BOOL
  352. AtqAddAsyncHandle(
  353. OUT PATQ_CONTEXT * ppatqContext,
  354. IN PVOID EndpointObject,
  355. IN PVOID ClientContext,
  356. IN ATQ_COMPLETION pfnCompletion,
  357. IN DWORD TimeOut,
  358. IN HANDLE hAsyncIO
  359. );
  360. dllexp
  361. VOID
  362. AtqGetAcceptExAddrs(
  363. IN PATQ_CONTEXT patqContext,
  364. OUT SOCKET * pSock,
  365. OUT PVOID * ppvBuff,
  366. OUT PVOID * pEndpointContext,
  367. OUT SOCKADDR * * ppsockaddrLocal,
  368. OUT SOCKADDR * * ppsockaddrRemote
  369. );
  370. /*++
  371. AtqCloseSocket()
  372. Routine Description:
  373. Closes the socket in this atq structure if it wasn't
  374. closed by transmitfile. This function should be called only
  375. if the embedded handle in AtqContext is a Socket.
  376. Arguments:
  377. patqContext - Context whose socket should be closed.
  378. fShutdown - If TRUE, means we call shutdown and always close the socket.
  379. Note that if TransmitFile closed the socket, it will have done the
  380. shutdown for us
  381. Returns:
  382. TRUE on success and FALSE if there is a failure.
  383. --*/
  384. dllexp
  385. BOOL
  386. AtqCloseSocket(
  387. PATQ_CONTEXT patqContext,
  388. BOOL fShutdown
  389. );
  390. /*++
  391. AtqCloseFileHandle()
  392. Routine Description:
  393. Closes the file handle in this atq structure.
  394. This function should be called only if the embedded handle
  395. in AtqContext is a file handle.
  396. Arguments:
  397. patqContext - Context whose file handle should be closed.
  398. Returns:
  399. TRUE on success and FALSE if there is a failure.
  400. --*/
  401. dllexp
  402. BOOL
  403. AtqCloseFileHandle(
  404. PATQ_CONTEXT patqContext
  405. );
  406. /*++
  407. AtqFreeContext()
  408. Routine Description:
  409. Frees the context created in AtqAddAsyncHandle.
  410. Call this after the async handle has been closed and all outstanding
  411. IO operations have been completed. The context is invalid after this call.
  412. Call AtqFreeContext() for same context only ONCE.
  413. Arguments:
  414. patqContext - Context to free
  415. fReuseContext - TRUE if this can context can be reused in the context of
  416. the calling thread. Should be FALSE if the calling thread will exit
  417. soon (i.e., isn't an AtqPoolThread).
  418. Returns:
  419. None
  420. --*/
  421. dllexp
  422. VOID
  423. AtqFreeContext(
  424. IN PATQ_CONTEXT patqContext,
  425. BOOL fReuseContext
  426. );
  427. enum ATQ_CONTEXT_INFO
  428. {
  429. ATQ_INFO_TIMEOUT = 0, // Timeout rounded up to ATQ timeout interval
  430. ATQ_INFO_RESUME_IO, // resumes IO as is after Timeout
  431. ATQ_INFO_COMPLETION, // Completion routine
  432. ATQ_INFO_COMPLETION_CONTEXT,// Completion context
  433. ATQ_INFO_BANDWIDTH_INFO, // Bandwidth Throttling Descriptor
  434. ATQ_INFO_ABORTIVE_CLOSE, // do abortive close on closesocket
  435. ATQ_INFO_NEXT_TIMEOUT
  436. };
  437. enum ATQ_CONSUMER_TYPE
  438. {
  439. AtqConsumerLDAP = 0,
  440. AtqConsumerOther,
  441. AtqConsumerAtq,
  442. AtqConsumerMax
  443. };
  444. /*++
  445. AtqContextSetInfo()
  446. Routine Description:
  447. Sets various bits of information for this context
  448. Arguments:
  449. patqContext - pointer to ATQ context
  450. atqInfo - Data item to set
  451. data - New value for item
  452. Return Value:
  453. The old value of the parameter
  454. --*/
  455. dllexp
  456. DWORD_PTR
  457. AtqContextSetInfo(
  458. IN PATQ_CONTEXT patqContext,
  459. IN enum ATQ_CONTEXT_INFO atqInfo,
  460. IN DWORD_PTR data
  461. );
  462. dllexp
  463. DWORD_PTR
  464. AtqContextSetInfo2(
  465. IN PATQ_CONTEXT patqContext,
  466. IN enum ATQ_CONTEXT_INFO atqInfo,
  467. IN DWORD_PTR data
  468. );
  469. VOID
  470. AtqUpdatePerfStats(
  471. IN ATQ_CONSUMER_TYPE ConsumerType,
  472. IN DWORD dwOperation,
  473. IN DWORD dwVal
  474. );
  475. dllexp
  476. DWORD_PTR
  477. AtqEndpointSetInfo2(
  478. IN PVOID Endpoint,
  479. IN ATQ_ENDPOINT_INFO EndpointInfo,
  480. IN DWORD_PTR dwInfo
  481. );
  482. dllexp
  483. DWORD_PTR
  484. AtqSetInfo2(
  485. IN ATQ_INFO atqInfo,
  486. IN DWORD_PTR Data
  487. );
  488. /*----------------------------------------------------------
  489. ATQ Context IO functions
  490. -----------------------------------------------------------*/
  491. /*++
  492. Routine Description:
  493. Atq<Operation><Target>()
  494. <Operation> := Read | Write | Transmit
  495. <Target> := File | Socket
  496. These functions just setup ATQ context and then call the corresponding
  497. Win32/WinSock function for submitting an asynchronous IO operation. By
  498. default the Socket functions support scatter/gather using WSABUF
  499. These functions are wrappers and should be called instead of the
  500. correpsonding Win32 API. The one difference from the Win32 API is TRUE
  501. is returned if the error ERROR_IO_PENDING occurred, thus clients do not
  502. need to check for this case.
  503. The timeout time for the request is calculated by taking the maximum of
  504. the context's timeout time and bytes transferred based on 1k/second.
  505. Arguments:
  506. patqContext - pointer to ATQ context
  507. Everything else as in the Win32 API/WinSock APIs
  508. NOTES: AtqTransmitFile takes an additional DWORD flags which may contain
  509. the winsock constants TF_DISCONNECT and TF_REUSE_SOCKET
  510. AtqReadFile and AtqWriteFile take an optional overlapped structure if
  511. clients want to have multiple outstanding reads or writes. If the value
  512. is NULL, then the overlapped structure from the Atq context is used.
  513. Return Value:
  514. TRUE if successful, FALSE on error (call GetLastError)
  515. sets ERROR_NETWORK_BUSY as error when the request needs to be rejected.
  516. --*/
  517. dllexp
  518. BOOL
  519. AtqReadFile(
  520. IN PATQ_CONTEXT patqContext,
  521. IN LPVOID lpBuffer,
  522. IN DWORD BytesToRead,
  523. IN OVERLAPPED * lpo OPTIONAL
  524. );
  525. dllexp
  526. BOOL
  527. AtqReadSocket(
  528. IN PATQ_CONTEXT patqContext,
  529. IN LPWSABUF pwsaBuffers,
  530. IN DWORD dwBufferCount,
  531. IN OVERLAPPED * lpo OPTIONAL
  532. );
  533. /*
  534. * Code for reading into single buffer will look like the following.
  535. * {
  536. * WSABUF wsaBuf = { (BytesToRead), (lpBuffer)};
  537. * fRet = AtqReadSocket( patqContext, &wsaBuf, 1, lpo);
  538. * }
  539. */
  540. dllexp
  541. BOOL
  542. AtqWriteFile(
  543. IN PATQ_CONTEXT patqContext,
  544. IN LPCVOID lpBuffer,
  545. IN DWORD BytesToWrite,
  546. IN OVERLAPPED * lpo OPTIONAL
  547. );
  548. dllexp
  549. BOOL
  550. AtqWriteSocket(
  551. IN PATQ_CONTEXT patqContext,
  552. IN LPWSABUF pwsaBuffers,
  553. IN DWORD dwBufferCount,
  554. IN OVERLAPPED * lpo OPTIONAL
  555. );
  556. dllexp
  557. BOOL
  558. AtqSyncWsaSend(
  559. IN PATQ_CONTEXT patqContext,
  560. IN LPWSABUF pwsaBuffers,
  561. IN DWORD dwBufferCount,
  562. OUT LPDWORD pcbWritten
  563. );
  564. // Note: This API always causes the complete file to be sent.
  565. // If you want to change the behaviour store the appropriate offsets
  566. // in the ATQ_CONTEXT::Overlapped object.
  567. dllexp
  568. BOOL
  569. AtqTransmitFile(
  570. IN PATQ_CONTEXT patqContext,
  571. IN HANDLE hFile, // File data comes from
  572. IN DWORD dwBytesInFile, // what is the size of file?
  573. IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
  574. IN DWORD dwFlags // TF_DISCONNECT, TF_REUSE_SOCKET
  575. );
  576. dllexp
  577. BOOL
  578. AtqTransmitFileAndRecv(
  579. IN PATQ_CONTEXT patqContext, // pointer to ATQ context
  580. IN HANDLE hFile, // handle of file to read
  581. IN DWORD dwBytesInFile, // Bytes to transmit
  582. IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, // transmit buffer structure
  583. IN DWORD dwTFFlags, // TF Flags
  584. IN LPWSABUF pwsaBuffers, // Buffers for recv
  585. IN DWORD dwBufferCount
  586. );
  587. dllexp
  588. BOOL
  589. AtqSendAndRecv(
  590. IN PATQ_CONTEXT patqContext, // pointer to ATQ context
  591. IN LPWSABUF pwsaSendBuffers, // buffers for send
  592. IN DWORD dwSendBufferCount, // count of buffers for send
  593. IN LPWSABUF pwsaRecvBuffers, // Buffers for recv
  594. IN DWORD dwRecvBufferCount // count of buffers for recv
  595. );
  596. /*----------------------------------------------------------
  597. ATQ Utility Functions
  598. -----------------------------------------------------------*/
  599. #define OPLOCK_BREAK_NO_OPLOCK 0x00000001
  600. #define OPLOCK_BREAK_OPEN 0x00000007
  601. #define OPLOCK_BREAK_CLOSE 0x00000008
  602. typedef
  603. VOID
  604. (*ATQ_OPLOCK_COMPLETION)(
  605. IN PVOID Context,
  606. IN DWORD Status
  607. );
  608. dllexp
  609. HANDLE
  610. AtqCreateFile(
  611. LPCSTR lpAFileName,
  612. DWORD dwShareMode,
  613. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  614. DWORD dwFlagsAndAttributes,
  615. SECURITY_INFORMATION si,
  616. PSECURITY_DESCRIPTOR sd,
  617. ULONG Length,
  618. PULONG LengthNeeded,
  619. ATQ_OPLOCK_COMPLETION pfnOplockCompletion,
  620. PVOID Context
  621. );
  622. dllexp
  623. HANDLE
  624. AtqCreateFileW(
  625. LPCWSTR lpFileName,
  626. DWORD dwShareMode,
  627. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  628. DWORD dwFlagsAndAttributes,
  629. SECURITY_INFORMATION si,
  630. PSECURITY_DESCRIPTOR sd,
  631. ULONG Length,
  632. PULONG LengthNeeded,
  633. ATQ_OPLOCK_COMPLETION pfnOplockCompletion,
  634. PVOID Context
  635. );
  636. dllexp
  637. BOOL
  638. AtqOplockAcknowledge(
  639. IN HANDLE FileHandle,
  640. ATQ_OPLOCK_COMPLETION pfnOplockCompletion,
  641. PVOID Context
  642. );
  643. dllexp
  644. BOOL
  645. AtqSpudInitialized(
  646. VOID
  647. );
  648. dllexp
  649. BOOL
  650. AtqReadDirChanges(PATQ_CONTEXT patqContext,
  651. LPVOID lpBuffer,
  652. DWORD BytesToRead,
  653. BOOL fWatchSubDir,
  654. DWORD dwNotifyFilter,
  655. OVERLAPPED * lpo );
  656. /*++
  657. AtqPostCompletionStatus()
  658. Routine Description:
  659. Posts a completion status on the completion port queue
  660. An IO pending error code is treated as a success error code
  661. Arguments:
  662. patqContext - pointer to ATQ context
  663. Everything else as in the Win32 API
  664. NOTES:
  665. Return Value:
  666. TRUE if successful, FALSE on error (call GetLastError)
  667. --*/
  668. dllexp
  669. BOOL
  670. AtqPostCompletionStatus(
  671. IN PATQ_CONTEXT patqContext,
  672. IN DWORD BytesTransferred
  673. );
  674. /*----------------------------------------------------------
  675. ATQ Utility Functions
  676. -----------------------------------------------------------*/
  677. /*++
  678. Bandwidth Throttling Support
  679. The following items are used in the support for bandwidth throttling
  680. --*/
  681. enum ATQ_BANDWIDTH_INFO
  682. {
  683. ATQ_BW_BANDWIDTH_LEVEL = 0,
  684. ATQ_BW_MAX_BLOCKED,
  685. ATQ_BW_STATISTICS,
  686. ATQ_BW_DESCRIPTION,
  687. };
  688. /*++
  689. AtqCreateBandwidthInfo()
  690. Routine Description:
  691. Allocate and opaque bandwidth descriptor
  692. Arguments:
  693. None
  694. Return Value:
  695. Pointer to descriptor. NULL if failed.
  696. --*/
  697. dllexp
  698. PVOID
  699. AtqCreateBandwidthInfo(
  700. VOID
  701. );
  702. /*++
  703. AtqFreeBandwidthInfo()
  704. Routine Description:
  705. Triggers the destruction of a bandwidth descriptor
  706. Arguments:
  707. pvBandwidthInfo - pointer to valid descriptor
  708. Return Value:
  709. TRUE if successful, else FALSE
  710. --*/
  711. dllexp
  712. BOOL
  713. AtqFreeBandwidthInfo(
  714. IN PVOID pvBandwidthInfo
  715. );
  716. /*++
  717. AtqBandwidthSetInfo()
  718. Routine Description:
  719. Set properties of bandwidth descriptor
  720. Arguments:
  721. pvBandwidthInfo - pointer to descriptor
  722. BWInfo - property to change
  723. Data - value of property
  724. Return Value:
  725. Old value of property
  726. --*/
  727. dllexp
  728. DWORD_PTR
  729. AtqBandwidthSetInfo(
  730. IN PVOID pvBandwidthInfo,
  731. IN ATQ_BANDWIDTH_INFO BwInfo,
  732. IN DWORD_PTR Data
  733. );
  734. /*++
  735. AtqBandwidthGetInfo()
  736. Routine Description:
  737. Get properties of bandwidth descriptor
  738. Arguments:
  739. pvBandwidthInfo - pointer to descriptor
  740. BWInfo - property to change
  741. pdwData - filled in with value of property
  742. Return Value:
  743. TRUE if successful, else FALSE
  744. --*/
  745. dllexp
  746. BOOL
  747. AtqBandwidthGetInfo(
  748. IN PVOID pvBandwidthInfo,
  749. IN ATQ_BANDWIDTH_INFO BwInfo,
  750. OUT DWORD_PTR * pdwData
  751. );
  752. #include "atq2.h"
  753. #ifdef __cplusplus
  754. }
  755. #endif
  756. #endif // !_ATQ_H_