|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <s32buf.h> |
|
17 #include "SqlPanic.h" |
|
18 #include "IPCStream.h" |
|
19 #include "SqlSrvResourceProfiler.h" |
|
20 |
|
21 /** |
|
22 Reads data from the stream buffer and sends them to the client. |
|
23 |
|
24 @param aMessage The client message. |
|
25 |
|
26 @return The number of bytes sent. |
|
27 |
|
28 Usage of the IPC call arguments: |
|
29 Arg 0: not used |
|
30 Arg 1: [in] from which position to read |
|
31 Arg 2: [in/out] IPC buffer |
|
32 Arg 3: [in] max length of the requested data |
|
33 */ |
|
34 TInt HIpcStream::ReadL(const RMessage2& aMessage) |
|
35 { |
|
36 TInt pos=aMessage.Int1(); |
|
37 if (pos!=iRPos) |
|
38 iHost.SeekL(iHost.ERead,EStreamBeginning,pos); |
|
39 iRPos=-1; |
|
40 TInt len=aMessage.Int3(); |
|
41 pos+=len; |
|
42 TInt tfr=len; |
|
43 for (;;) |
|
44 { |
|
45 TUint8 buf[KIpcStreamSize]; |
|
46 TInt read=iHost.ReadL(buf,Min(tfr,KIpcStreamSize)); |
|
47 if (read==0) |
|
48 break; |
|
49 aMessage.WriteL(2,TPtrC8(buf,read),len-tfr); |
|
50 SQLPROFILER_REPORT_IPC(ESqlIpcWrite, read); |
|
51 tfr-=read; |
|
52 if (tfr==0) |
|
53 break; |
|
54 if (read<KIpcStreamSize) |
|
55 break; |
|
56 } |
|
57 iRPos=pos-tfr; |
|
58 return len-tfr; |
|
59 } |
|
60 |
|
61 /** |
|
62 Reads data from the client message and stores the data in the stream buffer. |
|
63 |
|
64 @param aMessage The client message. |
|
65 |
|
66 @return The number of bytes read and stored in the stream buffer. |
|
67 |
|
68 |
|
69 Usage of the IPC call arguments: |
|
70 Arg 0: not used |
|
71 Arg 1: [in] from which position to write |
|
72 Arg 2: [in/out] IPC buffer |
|
73 */ |
|
74 void HIpcStream::WriteL(const RMessage2& aMessage) |
|
75 { |
|
76 TInt pos=aMessage.Int1(); |
|
77 if (pos!=iWPos) |
|
78 iHost.SeekL(iHost.EWrite,EStreamBeginning,pos); |
|
79 iWPos=-1; |
|
80 TInt offset=0; |
|
81 TBuf8<KIpcStreamSize> buf; |
|
82 for (;;) |
|
83 { |
|
84 aMessage.ReadL(2,buf,offset); |
|
85 TInt len=buf.Length(); |
|
86 SQLPROFILER_REPORT_IPC(ESqlIpcRead, len); |
|
87 if (len==0) |
|
88 break; |
|
89 iHost.WriteL(buf.Ptr(),len); |
|
90 offset+=len; |
|
91 if (len<KIpcStreamSize) |
|
92 break; |
|
93 } |
|
94 iWPos=pos+offset; |
|
95 } |
|
96 |
|
97 /** |
|
98 Destroys HIpcReadBuf object. |
|
99 */ |
|
100 void HIpcReadBuf::DoRelease() |
|
101 { |
|
102 delete this; |
|
103 } |