Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
system
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
_site-res
system
Commits
1b075448
Commit
1b075448
authored
Jul 11, 2018
by
tufengqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix steam with swoole
parent
016c48f8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
TPhpStream.php
classes/fpf/thrift/TPhpStream.php
+15
-6
No files found.
classes/fpf/thrift/TPhpStream.php
View file @
1b075448
...
...
@@ -45,7 +45,7 @@ class TPhpStream extends TTransport
private
$write_
=
false
;
private
static
$fd
;
private
$fd
;
public
function
__construct
(
$mode
)
{
...
...
@@ -53,21 +53,21 @@ class TPhpStream extends TTransport
$this
->
write_
=
$mode
&
self
::
MODE_W
;
}
public
static
function
getFd
()
public
function
getFd
()
{
return
self
::
$
fd
;
return
$this
->
fd
;
}
public
static
function
setFd
(
$fd
)
public
function
setFd
(
$fd
)
{
self
::
$
fd
=
$fd
;
$this
->
fd
=
$fd
;
}
public
function
open
()
{
if
(
$this
->
read_
)
{
if
(
defined
(
'IS_SWOOLE_SERVICE'
)
&&
true
===
IS_SWOOLE_SERVICE
)
{
$this
->
inStream_
=
self
::
$
fd
;
$this
->
inStream_
=
$this
->
fd
;
}
else
{
$this
->
inStream_
=
@
fopen
(
self
::
inStreamName
(),
'r'
);
}
...
...
@@ -102,7 +102,12 @@ class TPhpStream extends TTransport
public
function
read
(
$len
)
{
if
(
defined
(
'IS_SWOOLE_SERVICE'
)
&&
IS_SWOOLE_SERVICE
===
true
)
{
fseek
(
$fp
,
$len
);
$data
=
co
::
fread
(
$fp
);
}
else
{
$data
=
@
fread
(
$this
->
inStream_
,
$len
);
}
if
(
$data
===
false
||
$data
===
''
)
{
throw
new
TException
(
'TPhpStream: Could not read '
.
$len
.
' bytes'
);
}
...
...
@@ -113,7 +118,11 @@ class TPhpStream extends TTransport
public
function
write
(
$buf
)
{
while
(
TStringFuncFactory
::
create
()
->
strlen
(
$buf
)
>
0
)
{
if
(
defined
(
'IS_SWOOLE_SERVICE'
)
&&
IS_SWOOLE_SERVICE
===
true
)
{
$got
=
co
::
fwrite
(
$this
->
outStream_
,
$buf
);
}
else
{
$got
=
@
fwrite
(
$this
->
outStream_
,
$buf
);
}
if
(
$got
===
0
||
$got
===
false
)
{
throw
new
TException
(
'TPhpStream: Could not write '
.
TStringFuncFactory
::
create
()
->
strlen
(
$buf
)
.
' bytes'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment