52 |
my $rVecRef=shift; |
my $rVecRef=shift; |
53 |
my $wVecRef=shift; |
my $wVecRef=shift; |
54 |
my $eVecRef=shift; |
my $eVecRef=shift; |
|
|
|
55 |
my @cons=@Connections; |
my @cons=@Connections; |
56 |
map {$_->addHandleBits($rVecRef,$wVecRef,$eVecRef) if(defined($_)) } @cons; |
map {$_->addHandleBits($rVecRef,$wVecRef,$eVecRef) if(defined($_)) } @cons; |
57 |
} |
} |
77 |
map { $_->close(); } @cons; |
map { $_->close(); } @cons; |
78 |
} |
} |
79 |
|
|
80 |
|
sub listConnections { |
81 |
|
my $class=shift; |
82 |
|
my $list=''; |
83 |
|
foreach my $conn (@Connections) { |
84 |
|
$list .= $conn->{'socketFN'}.' '.$conn->{'ip'}.' '.$conn->{'type'}; |
85 |
|
if (exists($conn->{'subscriberID'})) { |
86 |
|
$list .= ' '.$conn->{'subscriberID'}; |
87 |
|
} |
88 |
|
$list .= "$::CRLF"; |
89 |
|
} |
90 |
|
$list; |
91 |
|
} |
92 |
|
|
93 |
|
sub describeConnWithFileNum { |
94 |
|
my $class=shift; |
95 |
|
my $filenum=shift; |
96 |
|
foreach my $conn (@Connections) { |
97 |
|
if ($conn->{'socketFN'}==$filenum) { |
98 |
|
my $ret = ""; |
99 |
|
if (exists($conn->{'socketFN'})) { |
100 |
|
$ret .= "socketFN: ".$conn->{'socketFN'}."$::CRLF"; |
101 |
|
} |
102 |
|
if (exists($conn->{'connectionStart'})) { |
103 |
|
$ret .= "connectionStart: ".$conn->{'connectionStart'}."$::CRLF"; |
104 |
|
} |
105 |
|
if (exists($conn->{'writeBuffer'})) { |
106 |
|
$ret .= "writeBuffer: ".$conn->{'writeBuffer'}."$::CRLF"; |
107 |
|
} |
108 |
|
if (exists($conn->{'readBuffer'})) { |
109 |
|
$ret .= "readBuffer: ".$conn->{'readBuffer'}."$::CRLF"; |
110 |
|
} |
111 |
|
if (exists($conn->{'bytesWritten'})) { |
112 |
|
$ret .= "bytesWritten: ".$conn->{'bytesWritten'}."$::CRLF"; |
113 |
|
} |
114 |
|
if (exists($conn->{'type'})) { |
115 |
|
$ret .= "type: ".$conn->{'type'}."$::CRLF"; |
116 |
|
} |
117 |
|
if (exists($conn->{'mode'})) { |
118 |
|
$ret .= "mode: ".$conn->{'mode'}."$::CRLF"; |
119 |
|
} |
120 |
|
if (exists($conn->{'ip'})) { |
121 |
|
$ret .= "ip: ".$conn->{'ip'}."$::CRLF"; |
122 |
|
} |
123 |
|
if (exists($conn->{'headerBuffer'})) { |
124 |
|
$ret .= "headerBuffer: ".$conn->{'headerBuffer'}."$::CRLF"; |
125 |
|
} |
126 |
|
if (exists($conn->{'messageCount'})) { |
127 |
|
$ret .= "messageCount: ".$conn->{'messageCount'}."$::CRLF"; |
128 |
|
} |
129 |
|
if (exists($conn->{'connectionStart'})) { |
130 |
|
$ret .= "age: ".(time-$conn->{'connectionStart'})."$::CRLF"; |
131 |
|
} |
132 |
|
if (exists($conn->{'connectionTimeLimit'})) { |
133 |
|
$ret .= "connectionTimeLimit: ".$conn->{'connectionTimeLimit'}."$::CRLF"; |
134 |
|
} |
135 |
|
if (exists($conn->{'useragent'})) { |
136 |
|
$ret .= "useragent: ".$conn->{'useragent'}."$::CRLF"; |
137 |
|
} |
138 |
|
if (exists($conn->{'subscriberID'})) { |
139 |
|
$ret .= "subscriberID: ".$conn->{'subscriberID'}."$::CRLF"; |
140 |
|
} |
141 |
|
return $ret; |
142 |
|
} |
143 |
|
} |
144 |
|
return -1; |
145 |
|
} |
146 |
|
|
147 |
|
sub destroyBadRequests { |
148 |
|
foreach my $conn (@Connections) { |
149 |
|
if (time-$conn->{'connectionStart'} > 30 && !exists($conn->{'subscriberID'}) && $conn->{'type'} eq 'Meteor::Subscriber') { |
150 |
|
&::syslog('debug',"Closing misbehaving subscriber %s",$conn->{'socketFN'}); |
151 |
|
$conn->close(); |
152 |
|
} |
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
############################################################################### |
############################################################################### |
157 |
# Factory methods |
# Factory methods |
158 |
############################################################################### |
############################################################################### |
180 |
|
|
181 |
$self->{'socket'}=$socket; |
$self->{'socket'}=$socket; |
182 |
$self->{'socketFN'}=$socket->fileno(); |
$self->{'socketFN'}=$socket->fileno(); |
183 |
|
$self->{'connectionStart'}=time; |
184 |
|
|
185 |
$socket->setNonBlocking(); |
$socket->setNonBlocking(); |
186 |
|
|
187 |
$self->{'writeBuffer'}=''; |
$self->{'writeBuffer'}=''; |
188 |
$self->{'readBuffer'}=''; |
$self->{'readBuffer'}=''; |
189 |
$self->{'bytesWritten'}=0; |
$self->{'bytesWritten'}=0; |
190 |
|
$self->{'type'}=ref($self); |
191 |
$self->{'ip'}=$socket->{'connection'}->{'remoteIP'}; |
$self->{'ip'}=$socket->{'connection'}->{'remoteIP'}; |
192 |
|
|
193 |
push(@Connections,$self); |
push(@Connections,$self); |
194 |
|
|
195 |
&::syslog('debug',"New %s for %s",ref($self),$socket->{'connection'}->{'remoteIP'}); |
&::syslog('debug',"New %s for %s using file number %s",ref($self),$self->{'ip'},$self->{'socketFN'}); |
196 |
|
|
197 |
$self; |
$self; |
198 |
} |
} |
386 |
} |
} |
387 |
|
|
388 |
1; |
1; |
|
############################################################################EOF |
|
389 |
|
############################################################################EOF |