Merge "Add volatile qualifier to boolean variable" into nyc-dev
This commit is contained in:
@@ -336,17 +336,17 @@ public class DhcpClient extends StateMachine {
|
|||||||
class ReceiveThread extends Thread {
|
class ReceiveThread extends Thread {
|
||||||
|
|
||||||
private final byte[] mPacket = new byte[DhcpPacket.MAX_LENGTH];
|
private final byte[] mPacket = new byte[DhcpPacket.MAX_LENGTH];
|
||||||
private boolean stopped = false;
|
private volatile boolean mStopped = false;
|
||||||
|
|
||||||
public void halt() {
|
public void halt() {
|
||||||
stopped = true;
|
mStopped = true;
|
||||||
closeSockets(); // Interrupts the read() call the thread is blocked in.
|
closeSockets(); // Interrupts the read() call the thread is blocked in.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (DBG) Log.d(TAG, "Receive thread started");
|
if (DBG) Log.d(TAG, "Receive thread started");
|
||||||
while (!stopped) {
|
while (!mStopped) {
|
||||||
int length = 0; // Or compiler can't tell it's initialized if a parse error occurs.
|
int length = 0; // Or compiler can't tell it's initialized if a parse error occurs.
|
||||||
try {
|
try {
|
||||||
length = Os.read(mPacketSock, mPacket, 0, mPacket.length);
|
length = Os.read(mPacketSock, mPacket, 0, mPacket.length);
|
||||||
@@ -355,7 +355,7 @@ public class DhcpClient extends StateMachine {
|
|||||||
if (DBG) Log.d(TAG, "Received packet: " + packet);
|
if (DBG) Log.d(TAG, "Received packet: " + packet);
|
||||||
sendMessage(CMD_RECEIVED_PACKET, packet);
|
sendMessage(CMD_RECEIVED_PACKET, packet);
|
||||||
} catch (IOException|ErrnoException e) {
|
} catch (IOException|ErrnoException e) {
|
||||||
if (!stopped) {
|
if (!mStopped) {
|
||||||
Log.e(TAG, "Read error", e);
|
Log.e(TAG, "Read error", e);
|
||||||
}
|
}
|
||||||
DhcpClientEvent.logEvent(IpConnectivityEvent.IPCE_DHCP_RECV_ERROR,
|
DhcpClientEvent.logEvent(IpConnectivityEvent.IPCE_DHCP_RECV_ERROR,
|
||||||
|
|||||||
Reference in New Issue
Block a user