Am I doing this right?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    Am I doing this right?

    I have an simple app that pulls UDP socket packets off a network, places
    that packet data in a structure, and places the structure into a vb.net
    Queue (use enqueue. and dequeue). Writes queue to SQL server
    In the form I have global decl.
    PUBLIC DataQueue as NEW QUEUE
    PUBLIC STRUCTURE myDataStruct (add some elements)

    In my ONRECEIVEI place the buffer data into myDataStruct and
    DataQueue.Enque ue(myDataStruct ).

    I also have a 100ms timer that does this:
    dim tmpStruct as NEW myDataStruct
    tmpStruct = DataQueue.Deque ue()
    write tmpStruct to SQL
    I've got a bool flag in the timer routine to keep it from running again
    until it finishes everthing

    Is there any kind of conflict that can occur here?
    If OnReceive fires and enqueues while timer is dequeueing?
    Some sort of deadlock???
    I debug.writeline when enqueueing to assure what goes in the queue, but
    sometimes when I dequeue the data it has a value from another packet
    (scrambled), though the enqueue showed fine. Happens rarely but does happen.
    I don't quite understand how the OS executes the code, reading and writing
    at what 'I guess' is the same time to that queue sometimes.
    Is the scenerio above OK to use or is there a better solution (more stable)
    than what I am doing?
    Thanks
    BUC



  • GhostInAK

    #2
    Re: Am I doing this right?

    Hello Buc,

    Is there somereason you dont just push the data direct to the DB? What's
    the Queue for?

    -Boo
    I have an simple app that pulls UDP socket packets off a network,
    places
    that packet data in a structure, and places the structure into a
    vb.net
    Queue (use enqueue. and dequeue). Writes queue to SQL server
    In the form I have global decl.
    PUBLIC DataQueue as NEW QUEUE
    PUBLIC STRUCTURE myDataStruct (add some elements)
    In my ONRECEIVEI place the buffer data into myDataStruct and
    DataQueue.Enque ue(myDataStruct ).
    >
    I also have a 100ms timer that does this:
    dim tmpStruct as NEW myDataStruct
    tmpStruct = DataQueue.Deque ue()
    write tmpStruct to SQL
    I've got a bool flag in the timer routine to keep it from running
    again
    until it finishes everthing
    Is there any kind of conflict that can occur here?
    If OnReceive fires and enqueues while timer is dequeueing?
    Some sort of deadlock???
    I debug.writeline when enqueueing to assure what goes in the queue,
    but
    sometimes when I dequeue the data it has a value from another packet
    (scrambled), though the enqueue showed fine. Happens rarely but does
    happen.
    I don't quite understand how the OS executes the code, reading and
    writing
    at what 'I guess' is the same time to that queue sometimes.
    Is the scenerio above OK to use or is there a better solution (more
    stable)
    than what I am doing?
    Thanks
    BUC

    Comment

    • Dennis

      #3
      RE: Am I doing this right?

      May want to look at synclock for the que.
      --
      Dennis in Houston


      "Buc" wrote:
      I have an simple app that pulls UDP socket packets off a network, places
      that packet data in a structure, and places the structure into a vb.net
      Queue (use enqueue. and dequeue). Writes queue to SQL server
      In the form I have global decl.
      PUBLIC DataQueue as NEW QUEUE
      PUBLIC STRUCTURE myDataStruct (add some elements)
      >
      In my ONRECEIVEI place the buffer data into myDataStruct and
      DataQueue.Enque ue(myDataStruct ).
      >
      I also have a 100ms timer that does this:
      dim tmpStruct as NEW myDataStruct
      tmpStruct = DataQueue.Deque ue()
      write tmpStruct to SQL
      I've got a bool flag in the timer routine to keep it from running again
      until it finishes everthing
      >
      Is there any kind of conflict that can occur here?
      If OnReceive fires and enqueues while timer is dequeueing?
      Some sort of deadlock???
      I debug.writeline when enqueueing to assure what goes in the queue, but
      sometimes when I dequeue the data it has a value from another packet
      (scrambled), though the enqueue showed fine. Happens rarely but does happen.
      I don't quite understand how the OS executes the code, reading and writing
      at what 'I guess' is the same time to that queue sometimes.
      Is the scenerio above OK to use or is there a better solution (more stable)
      than what I am doing?
      Thanks
      BUC
      >
      >
      >
      >

      Comment

      • buc

        #4
        Re: Am I doing this right?

        A Little History.. The DB has one table that gets the inserted packets and a
        SQL Stored Proc gets the inserted data and places it in other table. The
        capture table is PURGED Every night. The captured table gets very big each
        day (spurt times)(10-100K) inserts (but purged at midnight)
        Since App receives thousands of packets, as the DB gets larger, the inserts
        slow down and it causes the .net receive socket to eventually PUKE if I did
        a straight insert, so I immead. throw them in a queue where they can get
        inserted fast as as SQL will let them. possible, leaving the receive socket
        cleared.
        Thanks BUC

        <Bucwrote in message news:%23WWM30Kw GHA.4384@TK2MSF TNGP04.phx.gbl. ..
        >I have an simple app that pulls UDP socket packets off a network, places
        >that packet data in a structure, and places the structure into a vb.net
        >Queue (use enqueue. and dequeue). Writes queue to SQL server
        In the form I have global decl.
        PUBLIC DataQueue as NEW QUEUE
        PUBLIC STRUCTURE myDataStruct (add some elements)
        >
        In my ONRECEIVEI place the buffer data into myDataStruct and
        DataQueue.Enque ue(myDataStruct ).
        >
        I also have a 100ms timer that does this:
        dim tmpStruct as NEW myDataStruct
        tmpStruct = DataQueue.Deque ue()
        write tmpStruct to SQL
        I've got a bool flag in the timer routine to keep it from running again
        until it finishes everthing
        >
        Is there any kind of conflict that can occur here?
        If OnReceive fires and enqueues while timer is dequeueing?
        Some sort of deadlock???
        I debug.writeline when enqueueing to assure what goes in the queue, but
        sometimes when I dequeue the data it has a value from another packet
        (scrambled), though the enqueue showed fine. Happens rarely but does
        happen.
        I don't quite understand how the OS executes the code, reading and writing
        at what 'I guess' is the same time to that queue sometimes.
        Is the scenerio above OK to use or is there a better solution (more
        stable) than what I am doing?
        Thanks
        BUC
        >
        >
        >

        Comment

        Working...