Knowledge Base

Debugging a multi-threaded application in VB .NET

Problem

The following subroutine is part of a client/server chat application written in VB .NET.  The code below is part of the chat client.  It runs in a separate thread from the main thread and listens indefinitely for incoming data from the chat server application.  The problem is that when the application is closed, the process keeps running in the background.  Please assist.

The chat client application contains a form with a button to connect to the chat server application via a TCP/IP socket connection:

thread01

The code “Dim ctThread As….” spawns a new thread that listens continuously (and indefinitely) for new incoming messages sent to listening clients by the chat server application.

Here you see the actual subroutine that is being run in a separate thread:

thread02

When you run the code in Visual Studio Express, you can step through the code, set breakpoints and see the familiar yellow marked line of text indicating the main thread code execution pointer.

When the chat client application is closed by closing the form,  the process keeps running however.  If I press CTRL-Break, I am presented with a green marked line of text indicating the sub-thread code execution pointer.

No matter what, it always seems to be executing instruction “serverStream=clientSocket.GetStream()”

I have to go into Task Manager and kill the chat client process to recover from this situation.

Can you assist please?

Continue Reading →

Debugging a multi-threaded application in VB .NET was last modified: March 24th, 2015 by tabcom

Linux server software RAID1 faulty HDD

Mitel SME server 7.5 running Centos 4.8
2x RAID1 (= hard disk mirror) volumes configured.
The first one is called /dev/md1 and is 106MB in size.
The second one is called /dev/md2 and is 79GB in size.

fdisk -l
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   fd  Linux raid autodetect
/dev/sda2              14        9729    78043770   fd  Linux raid autodetect

cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda1[1]
104320 blocks [2/1] [_U]

md2 : active raid1 sda2[1]
78043648 blocks [2/1] [_U]

mdadm -D /dev/md1
/dev/md1:
Version : 00.90.03
Creation Time : Tue Feb  9 18:23:06 2010
Raid Level : raid1
Array Size : 104320 (101.89 MiB 106.82 MB)
Used Dev Size : 104320 (101.89 MiB 106.82 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 1
Persistence : Superblock is persistent

Update Time : Sat Oct 29 14:29:04 2011
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

UUID : 75033f39:83173411:7e4c09d0:950cf5d3
Events : 0.50

Number   Major   Minor   RaidDevice State
0       0        0        0      removed
1       8        1        1      active sync   /dev/sda1

mdadm -D /dev/md2
/dev/md2:
Version : 00.90.03
Creation Time : Tue Feb  9 18:23:06 2010
Raid Level : raid1
Array Size : 78043648 (74.43 GiB 79.92 GB)
Used Dev Size : 78043648 (74.43 GiB 79.92 GB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 2
Persistence : Superblock is persistent

Update Time : Sat Oct 29 14:36:08 2011
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

UUID : e2d7cddf:055ea73c:0bdde8e9:f9e08fd4
Events : 0.67312

Number   Major   Minor   RaidDevice State
0       0        0        0      removed
1       8        2        1      active sync   /dev/sda2

Shut down the computer, temporarily disconnect the power cord, swap the faulty hard disk for a new hard disk and and power up the system.
We will now attempt to rebuild the RAID1 mirror hard disk set [‘syncing’].  This will make changes to the operating system.

fdisk -l
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   fd  Linux raid autodetect
/dev/sda2              14        9729    78043770   fd  Linux raid autodetect

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn’t contain a valid partition table

fdisk /dev/sdb
The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801): 13

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-60801, default 14): 14
Last cylinder or +size or +sizeM or +sizeK (14-60801, default 60801): [ENTER]
Using default value 60801

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

mdadm –add /dev/md1 /dev/sdb1
mdadm: added /dev/sdb1

mdadm –add /dev/md2 /dev/sdb2
mdadm: added /dev/sdb2

cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb1[0] sda1[1]
104320 blocks [2/2] [UU]

md2 : active raid1 sdb2[2] sda2[1]
78043648 blocks [2/1] [_U]
[>………………..]  recovery =  1.1% (881536/78043648) finish=27.7min speed=46396K/sec
The RAID 1 mirror hard disk set is rebuilding.  In about 30 minutes the operation should have completed and your system will be fully operational.

RAID1 mirror hard disk set has been successfully rebuilt using the replacement hard disk installed in the system.

 

AFTER BEFORE
cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb1[0] sda1[1]
104320 blocks [2/2] [UU]md2 : active raid1 sdb2[0] sda2[1]
78043648 blocks [2/2] [UU]unused devices: none
cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda1[1]
104320 blocks [2/1] [_U]md2 : active raid1 sda2[1]
78043648 blocks [2/1] [_U]unused devices: none

It seems hardly worth the effort, but ‘2/1’ versus ‘2/2’ really makes a lot of difference.

‘2/1’ indicates that of the expected 2 devices, only 1 device is present; the RAID 1 mirror hard disk set is running in ‘degraded’ mode. With software RAID you manually have to reconfigure the RAID set once repairs have been completed.  This operation is called ‘syncing’ or ‘rebuilding’ of the RAID set. Hardware raid (= a dedicated RAID controller card installed in a server) allows for hot-swapping of hard disks and performs these operations automatically.

Linux server software RAID1 faulty HDD was last modified: March 24th, 2015 by tabcom

CSS style priority

The priority level of the selector is decided by importance of selectors:

  • style attribute = a
  • number of ID attributes (# id=) in the selector = b
  • number of other attributes and pseudo-classes (. class=) in the selector = c
  • number of element names and pseudo-elements (<article>, <p>, <span>, etc.) in the selector = d

Continue Reading →

CSS style priority was last modified: May 26th, 2015 by tabcom