Search Results

Search found 4181 results on 168 pages for 'exit'.

Page 12/168 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • How do I refactor code into a subroutine but allow for early exit?

    - by deworde
    There's a really obvious refactoring opportunity in this (working) code. bool Translations::compatibleNICodes(const Rule& rule, const std::vector<std::string>& nicodes) { bool included = false; // Loop through the ni codes. for(std::vector<std::string> iter = nicodes.begin(); iter != nicodes.end(); ++iter) { // Match against the ni codes of the rule if(rule.get_ni1() == *iter) { // If there's a match, check if the rule is include or exclude const std::string flag = rule.get_op1(); // If include, code is included unless a later rule excludes it if(flag == "INCLUDE"){ included = true; } // If exclude, code is specifically excluded else if(flag == "EXCLUDE"){ return false; } } if(rule.get_ni2() == *iter) { const std::string flag = rule.get_op2(); if(flag == "INCLUDE"){ included = true; } else if(flag == "EXCLUDE"){ return false; } } if(rule.get_ni3() == *iter) { const std::string flag = rule.get_op3(); if(flag == "INCLUDE"){ included = true; } else if(flag == "EXCLUDE"){ return false; } } if(rule.get_ni4() == *iter) { const std::string flag = rule.get_op4(); if(flag == "INCLUDE"){ included = true; } else if(flag == "EXCLUDE"){ return false; } } if(rule.get_ni5() == *iter) { const std::string flag = rule.get_op5(); if(flag == "INCLUDE"){ included = true; } else if(flag == "EXCLUDE"){ return false; } } } return included; } The problem is that I can't get around the problem that I want to exit early if it's an exclude statement. Note that I can't change the structure of the Rule class. Any advice?

    Read the article

  • Quick Question, robots.txt Disallow: /*/ does what exactly?

    - by Exit
    A SEO firm suggested changing the robots.txt to: User-agent: * Disallow: /*/ Allow: /ims/ I'm not sure what that would do, but my guess is that is would tell all robots to index nothing but the ims folder. I understand the wildcard, but I'm confused by the slashes and don't know how they would play out in conjunction with the wildcard. * Update * I didn't mention that there is a sitemap listed in the robots.txt file, but according to one tech blogger, he realized that sitemaps trump robots exclusions. So, even though this says in Google Webmaster Tools that everything with a trailing slash will not be indexed, the sitemap contains the important links. I did notice that the link count on Google went from 360 to 336, and the sitemap links under the URL scaled back to 3 from 6. I'm not sure the cause or what links were removed, though. Perhaps it cleaned out garbage. I'm still clueless why they would add in 'Allow: /ims/', that seems pointless. And a quick list of what would index according to the robots rules above (withouth the sitemap) using /*/: domain.com Indexed domain.com/page.html Indexed domain.com/folder/ Not Indexed domain.com/folder/page.html Not Indexed

    Read the article

  • SSH login with expect(1). How to exit expect and remain in SSH?

    - by Koroviev
    So I wanted to automate my SSH logins. The host I'm with doesn't allow key authentication on this server, so I had to be more inventive. I don't know much about shell scripting, but some research showed me the command 'expect' and some scripts using it for exactly this purpose. I set up a script and ran it, it worked perfectly to login. #!/usr/bin/env expect -f set password "my_password" match_max 1000 spawn ssh -p 2222 "my_username"@11.22.11.22 expect "*?assword:*" send -- "$password\r" send -- "\r" expect eof Initially, it runs as it should. Last login: Wed May 12 21:07:52 on ttys002 esther:~ user$ expect expect-test.exp spawn ssh -p 2222 [email protected] [email protected]'s password: Last login: Wed May 12 15:44:43 2010 from 20.10.20.10 -jailshell-3.2$ But that's where the success ends. Commands do not work, but hitting enter just makes a new line. Arrow keys and other non-alphanumeric keys produce symbols like '^[[C', '^[[A', '^[OQ' etc.[1] No other prompt appears except the two initially created by the expect script. Any ignored commands will be executed by my local shell once expect times out. An example: -jailshell-3.2$ whoami ls pwd hostname (...time passes, expect times out...) esther:~ user$ whoami user esther:~ ciaran$ ls Books Documents Movies Public Code Downloads Music Sites Desktop Library Pictures expect-test.exp esther:~ ciaran$ pwd /Users/ciaran esther:~ ciaran$ hostname esther.local As I said, I have no shell scripting experience, but I think it's being caused because I'm still "inside of" expect, but not "inside of" SSH. Is there any way to terminate expect once I've logged in, and have it hand over the SSH session to me? I've tried commands like 'close' and 'exit', after " send -- "\r" ". Yeah, they do what I want and expect dies, but it vindictively takes the SSH session down with it, leaving me back where I started. What I really need is for expect to do its job and terminate, leaving the SSH session back in my hands as if I did it manually. All help is appreciated, thanks. [1] I know there's a name for this, but I don't know what it is. And this is one of those frightening things which can't be googled, because the punctuation characters are ignored. As a side question, what's the story here?

    Read the article

  • Need some help on how to replay the last game of a java maze game

    - by Marty
    Hello, I am working on creating a Java maze game for a project. The maze is displayed on the console as standard output not in an applet. I have created most of hte code I need, however I am stuck at one problem and that is I need a user to be able to replay the last game i.e redraw the maze with the users moves but without any input from the user. I am not sure on what course of action to take, i was thinking about copying each users move or the position of each move into another array, as you can see i have 2 variables which hold the position of the player, plyrX and plyrY do you think copying these values into a new array after each move would solve my problem and how would i go about this? I have updated my code, apologies about the textIO.java class not being present, not sure how to resolve that exept post a link to TextIO.java [TextIO.java][1] My code below is updated with a new array of type char to hold values from the original maze (read in from text file and displayed using unicode characters) and also to new variables c_plyrX and c_plyrY which I am thinking should hold the values of plyrX and plyrY and copy them into the new array. When I try to call the replayGame(); method from the menu the maze loads for a second then the console exits so im not sure what I am doing wrong Thanks public class MazeGame { //unicode characters that will define the maze walls, //pathways, and in game characters. final static char WALL = '\u2588'; //wall final static char PATH = '\u2591'; //pathway final static char PLAYER = '\u25EF'; //player final static char ENTRANCE = 'E'; //entrance final static char EXIT = '\u2716'; //exit //declaring member variables which will hold the maze co-ordinates //X = rows, Y = columns static int entX = 0; //entrance X co-ordinate static int entY = 1; //entrance y co-ordinate static int plyrX = 0; static int plyrY = 1; static int exitX = 24; //exit X co-ordinate static int exitY = 37; //exit Y co-ordinate //static member variables which hold maze values //used so values can be accessed from different methods static int rows; //rows variable static int cols; //columns variable static char[][] maze; //defines 2 dimensional array to hold the maze //variables that hold player movement values static char dir; //direction static int spaces; //amount of spaces user can travel //variable to hold amount of moves the user has taken; static int movesTaken = 0; //new array to hold player moves for replaying game static char[][] mazeCopy; static int c_plyrX; static int c_plyrY; /** userMenu method for displaying the user menu which will provide various options for * the user to choose such as play a maze game, get instructions, etc. */ public static void userMenu(){ TextIO.putln("Maze Game"); TextIO.putln("*********"); TextIO.putln("Choose an option."); TextIO.putln(""); TextIO.putln("1. Play the Maze Game."); TextIO.putln("2. View Instructions."); TextIO.putln("3. Replay the last game."); TextIO.putln("4. Exit the Maze Game."); TextIO.putln(""); int option; //variable for holding users option TextIO.put("Type your choice: "); option = TextIO.getlnInt(); //gets users option //switch statement for processing menu options switch(option){ case 1: playMazeGame(); case 2: instructions(); case 3: if (c_plyrX == plyrX && c_plyrY == plyrY)replayGame(); else { TextIO.putln("Option not available yet, you need to play a game first."); TextIO.putln(); userMenu(); } case 4: System.exit(0); //exits the user out of the console default: TextIO.put("Option must be 1, 2, 3 or 4"); } } //end of userMenu /**main method, will call the userMenu and get the users choice and call * the relevant method to execute the users choice. */ public static void main(String[]args){ userMenu(); //calls the userMenu method } //end of main method /**instructions method, displays instructions on how to play * the game to the user/ */ public static void instructions(){ TextIO.putln("To beat the Maze Game you have to move your character"); TextIO.putln("through the maze and reach the exit in as few moves as possible."); TextIO.putln(""); TextIO.putln("Your characer is displayed as a " + PLAYER); TextIO.putln("The maze exit is displayed as a " + EXIT); TextIO.putln("Reach the exit and you have won escaped the maze."); TextIO.putln("To control your character type the direction you want to go"); TextIO.putln("and how many spaces you want to move"); TextIO.putln("for example 'D3' will move your character"); TextIO.putln("down 3 spaces."); TextIO.putln("Remember you can't walk through walls!"); boolean insOption; //boolean variable TextIO.putln(""); TextIO.put("Do you want to play the Maze Game now? (Y or N) "); insOption = TextIO.getlnBoolean(); if (insOption == true)playMazeGame(); else userMenu(); } //end of instructions method /**playMazeGame method, calls the loadMaze method and the charMove method * to start playing the Maze Game. */ public static void playMazeGame(){ loadMaze(); plyrMoves(); } //end of playMazeGame method /**loadMaze method, loads the 39x25 maze from the MazeGame.txt text file * and inserts values from the text file into the maze array and * displays the maze on screen using the unicode block characters. * plyrX and plyrY variables are set at their staring co ordinates so that when * a game is completed and the user selects to play a new game * the player character will always be at position 01. */ public static void loadMaze(){ plyrX = 0; plyrY = 1; TextIO.readFile("MazeGame.txt"); //now reads from the external MazeGame.txt file rows = TextIO.getInt(); //gets the number of rows from text file to create X dimensions cols = TextIO.getlnInt(); //gets number of columns from text file to create Y dimensions maze = new char[rows][cols]; //creates maze array of base type char with specified dimnensions //loop to process the array and read in values from the text file. for (int i = 0; i<rows; i++){ for (int j = 0; j<cols; j++){ maze[i][j] = TextIO.getChar(); } TextIO.getln(); } //end for loop TextIO.readStandardInput(); //closes MazeGame.txt file and reads from //standard input. //loop to process the array values and display as unicode characters for (int i = 0; i<rows; i++){ for (int j = 0; j<cols; j++){ if (i == plyrX && j == plyrY){ plyrX = i; plyrY = j; TextIO.put(PLAYER); //puts the player character at player co-ords } else{ if (maze[i][j] == '0') TextIO.putf("%c",WALL); //puts wall block if (maze[i][j] == '1') TextIO.putf("%c",PATH); //puts path block if (maze[i][j] == '2') { entX = i; entY = j; TextIO.putf("%c",ENTRANCE); //puts entrance character } if (maze[i][j] == '3') { exitX = i; //holds value of exit exitY = j; //co-ordinates TextIO.putf("%c",EXIT); //puts exit character } } } TextIO.putln(); } //end for loop } //end of loadMaze method /**redrawMaze method, method for redrawing the maze after each move. * */ public static void redrawMaze(){ TextIO.readFile("MazeGame.txt"); //now reads from the external MazeGame.txt file rows = TextIO.getInt(); //gets the number of rows from text file to create X dimensions cols = TextIO.getlnInt(); //gets number of columns from text file to create Y dimensions maze = new char[rows][cols]; //creates maze array of base type char with specified dimnensions //loop to process the array and read in values from the text file. for (int i = 0; i<rows; i++){ for (int j = 0; j<cols; j++){ maze[i][j] = TextIO.getChar(); } TextIO.getln(); } //end for loop TextIO.readStandardInput(); //closes MazeGame.txt file and reads from //standard input. //loop to process the array values and display as unicode characters for (int i = 0; i<rows; i++){ for (int j = 0; j<cols; j++){ if (i == plyrX && j == plyrY){ plyrX = i; plyrY = j; TextIO.put(PLAYER); //puts the player character at player co-ords } else{ if (maze[i][j] == '0') TextIO.putf("%c",WALL); //puts wall block if (maze[i][j] == '1') TextIO.putf("%c",PATH); //puts path block if (maze[i][j] == '2') { entX = i; entY = j; TextIO.putf("%c",ENTRANCE); //puts entrance character } if (maze[i][j] == '3') { exitX = i; //holds value of exit exitY = j; //co-ordinates TextIO.putf("%c",EXIT); //puts exit character } } } TextIO.putln(); } //end for loop } //end redrawMaze method /**replay game method * */ public static void replayGame(){ c_plyrX = plyrX; c_plyrY = plyrY; TextIO.readFile("MazeGame.txt"); //now reads from the external MazeGame.txt file rows = TextIO.getInt(); //gets the number of rows from text file to create X dimensions cols = TextIO.getlnInt(); //gets number of columns from text file to create Y dimensions mazeCopy = new char[rows][cols]; //creates maze array of base type char with specified dimnensions //loop to process the array and read in values from the text file. for (int i = 0; i<rows; i++){ for (int j = 0; j<cols; j++){ mazeCopy[i][j] = TextIO.getChar(); } TextIO.getln(); } //end for loop TextIO.readStandardInput(); //closes MazeGame.txt file and reads from //standard input. //loop to process the array values and display as unicode characters for (int i = 0; i<rows; i++){ for (int j = 0; j<cols; j++){ if (i == c_plyrX && j == c_plyrY){ c_plyrX = i; c_plyrY = j; TextIO.put(PLAYER); //puts the player character at player co-ords } else{ if (mazeCopy[i][j] == '0') TextIO.putf("%c",WALL); //puts wall block if (mazeCopy[i][j] == '1') TextIO.putf("%c",PATH); //puts path block if (mazeCopy[i][j] == '2') { entX = i; entY = j; TextIO.putf("%c",ENTRANCE); //puts entrance character } if (mazeCopy[i][j] == '3') { exitX = i; //holds value of exit exitY = j; //co-ordinates TextIO.putf("%c",EXIT); //puts exit character } } } TextIO.putln(); } //end for loop } //end replayGame method /**plyrMoves method, method for moving the players character * around the maze. */ public static void plyrMoves(){ int nplyrX = plyrX; int nplyrY = plyrY; int pMoves; direction(); //UP if (dir == 'U' || dir == 'u'){ nplyrX = plyrX; nplyrY = plyrY; for(pMoves = 0; pMoves <= spaces; pMoves++){ if (maze[nplyrX][nplyrY] == '0'){ TextIO.putln("Invalid move, try again."); } else if (pMoves != spaces){ nplyrX =plyrX + 1; } else { plyrX = plyrX-spaces; c_plyrX = plyrX; movesTaken++; } } }//end UP if //DOWN if (dir == 'D' || dir == 'd'){ nplyrX = plyrX; nplyrY = plyrY; for (pMoves = 0; pMoves <= spaces; pMoves ++){ if (maze[nplyrX][nplyrY] == '0'){ TextIO.putln("Invalid move, try again"); } else if (pMoves != spaces){ nplyrX = plyrX+1; } else{ plyrX = plyrX+spaces; c_plyrX = plyrX; movesTaken++; } } } //end DOWN if //LEFT if (dir == 'L' || dir =='l'){ nplyrX = plyrX; nplyrY = plyrY; for (pMoves = 0; pMoves <= spaces; pMoves++){ if (maze[nplyrX][nplyrY] == '0'){ TextIO.putln("Invalid move, try again"); } else if (pMoves != spaces){ nplyrY = plyrY + 1; } else{ plyrY = plyrY-spaces; c_plyrY = plyrY; movesTaken++; } } } //end LEFT if //RIGHT if (dir == 'R' || dir == 'r'){ nplyrX = plyrX; nplyrY = plyrY; for (pMoves = 0; pMoves <= spaces; pMoves++){ if (maze[nplyrX][nplyrY] == '0'){ TextIO.putln("Invalid move, try again."); } else if (pMoves != spaces){ nplyrY += 1; } else{ plyrY = plyrY+spaces; c_plyrY = plyrY; movesTaken++; } } } //end RIGHT if //prints message if player escapes from the maze. if (maze[plyrX][plyrY] == '3'){ TextIO.putln("****Congratulations****"); TextIO.putln(); TextIO.putln("You have escaped from the maze."); TextIO.putln(); userMenu(); } else{ movesTaken++; redrawMaze(); plyrMoves(); } } //end of plyrMoves method /**direction, method * */ public static char direction(){ TextIO.putln("Enter the direction you wish to move in and the distance"); TextIO.putln("i.e D3 = move down 3 spaces"); TextIO.putln("U - Up, D - Down, L - Left, R - Right: "); dir = TextIO.getChar(); if (dir =='U' || dir == 'D' || dir == 'L' || dir == 'R' || dir == 'u' || dir == 'd' || dir == 'l' || dir == 'r'){ spacesMoved(); } else{ loadMaze(); TextIO.putln("Invalid direction!"); TextIO.put("Direction must be one of U, D, L or R"); direction(); } return dir; //returns the value of dir (direction) } //end direction method /**spaces method, gets the amount of spaces the user wants to move * */ public static int spacesMoved(){ TextIO.putln(" "); spaces = TextIO.getlnInt(); if (spaces <= 0){ loadMaze(); TextIO.put("Invalid amount of spaces, try again"); spacesMoved(); } return spaces; } //end spacesMoved method } //end of MazeGame class

    Read the article

  • Print driver installs failing

    - by Kasius
    All of the Windows 7 64-bit Enterprise machines in my organization are failing to install a good number of printer drivers that previously installed without issue. This only happens with printer drivers. And not with all printer drivers. Just some. Network drivers, video drivers, etc. have had no problems. Here is part of setupapi.dev.log for a Dymo LabelWriter printer driver that is failing to install: dvi: {Plug and Play Service: Device Install for USBPRINT\DYMOLABELWRITER_450_TURBO\6&538F51D&0&USB001} ump: Creating Install Process: DrvInst.exe 09:36:58.071 ndv: Infpath=C:\Windows\INF\oem0.inf ndv: DriverNodeName=dymo.inf:DYMO.NTamd64.6.0:LW_450_TURBO_VISTA:8.1.0.363:usbprint\dymolabelwriter_450_aa08 ndv: DriverStorepath=C:\Windows\System32\DriverStore\FileRepository\dymo.inf_amd64_neutral_3a631b118b7a5828\dymo.inf ndv: Building driver list from driver node strong name... dvi: Searching for hardware ID(s): dvi: usbprint\dymolabelwriter_450_aa08 dvi: dymolabelwriter_450_aa08 inf: Opened PNF: 'C:\Windows\System32\DriverStore\FileRepository\dymo.inf_amd64_neutral_3a631b118b7a5828\dymo.inf' ([strings]) dvi: Selected driver installs from section [LW_450_TURBO_VISTA] in 'c:\windows\system32\driverstore\filerepository\dymo.inf_amd64_neutral_3a631b118b7a5828\dymo.inf'. dvi: Class GUID of device changed to: {4d36e979-e325-11ce-bfc1-08002be10318}. dvi: Set selected driver complete. ndv: {Core Device Install} 09:36:58.133 inf: Opened INF: 'C:\Windows\INF\oem0.inf' ([strings]) inf: Saved PNF: 'C:\Windows\INF\oem0.PNF' (Language = 0409) dvi: {DIF_ALLOW_INSTALL} 09:36:58.164 dvi: Using exported function 'ClassInstall32' in module 'C:\Windows\system32\ntprint.dll'. dvi: Class installer == ntprint.dll,ClassInstall32 dvi: No CoInstallers found dvi: Class installer: Enter 09:36:58.164 dvi: Class installer: Exit dvi: Default installer: Enter 09:36:58.180 dvi: Default installer: Exit dvi: {DIF_ALLOW_INSTALL - exit(0xe000020e)} 09:36:58.180 ndv: Installing files... dvi: {DIF_INSTALLDEVICEFILES} 09:36:58.180 dvi: Class installer: Enter 09:36:58.180 inf: Opened INF: 'C:\Windows\System32\DriverStore\FileRepository\dymo.inf_amd64_neutral_3a631b118b7a5828\dymo.inf' ([strings]) inf: Opened INF: 'C:\Windows\System32\DriverStore\FileRepository\dymo.inf_amd64_neutral_3a631b118b7a5828\dymo.inf' ([strings]) !!! dvi: Class installer: failed(0x00000490)! !!! dvi: Error 1168: Element not found. dvi: {DIF_INSTALLDEVICEFILES - exit(0x00000490)} 09:37:22.063 ndv: Device install status=0x00000490 ndv: Performing device install final cleanup... ! ndv: Queueing up error report since device installation failed... ndv: {Core Device Install - exit(0x00000490)} 09:37:22.063 dvi: {DIF_DESTROYPRIVATEDATA} 09:37:22.063 dvi: Class installer: Enter 09:37:22.063 dvi: Class installer: Exit dvi: Default installer: Enter 09:37:22.063 dvi: Default installer: Exit dvi: {DIF_DESTROYPRIVATEDATA - exit(0xe000020e)} 09:37:22.063 ump: Server install process exited with code 0x00000490 09:37:22.063 ump: {Plug and Play Service: Device Install exit(00000490)} Notice these lines in particular: !!! dvi: Class installer: failed(0x00000490)! !!! dvi: Error 1168: Element not found. dvi: {DIF_INSTALLDEVICEFILES - exit(0x00000490)} 09:37:22.063 ndv: Device install status=0x00000490 From what I have read, the "Element not found" error should be accompanied by an event describing what element was not found. The error that appears in Device Manager is "The driver cannot be installed because it is either not digitally signed or not signed in the appropriate manner." It appears to be signed fine though. It has an accompanying .CAT file and worked previously. And when installing, the following messages are logged in setupapi.dev.log: sto: {DRIVERSTORE_IMPORT_NOTIFY_VALIDATE} 09:36:56.277 inf: Opened INF: 'C:\Windows\System32\DriverStore\Temp\{272e2305-961c-7942-9ede-966f01047043}\dymo.inf' ([strings]) sig: {_VERIFY_FILE_SIGNATURE} 09:36:56.292 sig: Key = dymo.inf sig: FilePath = C:\Windows\System32\DriverStore\Temp\{272e2305-961c-7942-9ede-966f01047043}\dymo.inf sig: Catalog = C:\Windows\System32\DriverStore\Temp\{272e2305-961c-7942-9ede-966f01047043}\DYMO.CAT sig: Success: File is signed in catalog. sig: {_VERIFY_FILE_SIGNATURE exit(0x00000000)} 09:36:56.355 sto: Validating driver package files against catalog 'DYMO.CAT'. sto: Driver package is valid. sto: {DRIVERSTORE_IMPORT_NOTIFY_VALIDATE exit(0x00000000)} 09:36:56.402 sto: Verified driver package signature: sto: Digital Signer Score = 0x0D000005 sto: Digital Signer Name = Microsoft Windows Hardware Compatibility Publisher Now here's where it gets strange. If I take it off the domain, it installs fine. But it doesn't seem to have anything to do with Group Policy. I moved the machine to an OU that blocks inheritance, ran a gpupdate, ran rsop.msc to verify, and tried again. And it still didn't work. Likewise, I removed a machine from the domain, manually set all of the domain Group Policy settings in gpedit.msc, and tried that way, and it worked fine. So it seems like the Group Policy settings are irrelevant. What other domain-related issue could be causing this though? Any ideas on what to try next would be greatly appreciated. I'm not sure where to go from here. Thanks!

    Read the article

  • can't install anything ,getting error "Sub-process /usr/bin/dpkg returned an error code (1)"

    - by soum
    i am getting error whenever tring to install or update anything. "Sub-process /usr/bin/dpkg returned an error code (1)" please help me i am just stopped with my ubuntu 11.10. no installation or update. th unknown argument `triggered' dpkg: error processing mtools (--configure): subprocess installed post-installation script returned error exit status 1 Processing triggers for network-manager-pptp-gnome ... No apport report written because MaxReports is reached already postinst called with unknown argument `triggered' dpkg: error processing network-manager-pptp-gnome (--configure): subprocess installed post-installation script returned error exit status 1 No apport report written because MaxReports is reached already Processing triggers for network-manager-pptp ... postinst called with unknown argument triggered' dpkg: error processing network-manager-pptp (--configure): subprocess installed post-installation script returned error exit status 1 No apport report written because MaxReports is reached already Processing triggers for network-manager-gnome ... /var/lib/dpkg/info/network-manager-gnome.postinst called with unknown argumenttriggered' dpkg: error processing network-manager-gnome (--configure): subprocess installed post-installation script returned error exit status 1 Processing triggers for network-manager ... No apport report written because MaxReports is reached already /var/lib/dpkg/info/network-manager.postinst called with unknown argument triggered' dpkg: error processing network-manager (--configure): subprocess installed post-installation script returned error exit status 1 No apport report written because MaxReports is reached already Processing triggers for mscompress ... postinst called with unknown argumenttriggered' dpkg: error processing mscompress (--configure): subprocess installed post-installation script returned error exit status 1 No apport report written because MaxReports is reached already Errors were encountered while processing: netbase mtr-tiny module-init-tools mountmanager mono-4.0-gac mousetweaks mozilla-plugin-vlc mtools network-manager-pptp-gnome network-manager-pptp network-manager-gnome network-manager mscompress E: Sub-process /usr/bin/dpkg returned an error code (1)

    Read the article

  • How to fix "Sub-process /usr/bin/dpkg returned an error code (1)" when installing and upgrading packages?

    - by soum
    I am getting this error whenever tring to install or update anything: "Sub-process /usr/bin/dpkg returned an error code (1)" I need help, as I cannot install or upgrade any packages on my Ubuntu 11.10 system. Here is the rest of the error: unknown argument `triggered' dpkg: error processing mtools (--configure): subprocess installed post-installation script returned error exit status 1 Processing triggers for network-manager-pptp-gnome ... No apport report written because MaxReports is reached already postinst called with unknown argument `triggered' dpkg: error processing network-manager-pptp-gnome (--configure): subprocess installed post-installation script returned error exit status 1 No apport report written because MaxReports is reached already Processing triggers for network-manager-pptp ... postinst called with unknown argument `triggered' dpkg: error processing network-manager-pptp (--configure): subprocess installed post-installation script returned error exit status 1 No apport report written because MaxReports is reached already Processing triggers for network-manager-gnome ... /var/lib/dpkg/info/network-manager-gnome.postinst called with unknown argument `triggered' dpkg: error processing network-manager-gnome (--configure): subprocess installed post-installation script returned error exit status 1 Processing triggers for network-manager ... No apport report written because MaxReports is reached already /var/lib/dpkg/info/network-manager.postinst called with unknown argument `triggered' dpkg: error processing network-manager (--configure): subprocess installed post-installation script returned error exit status 1 No apport report written because MaxReports is reached already Processing triggers for mscompress ... postinst called with unknown argument `triggered' dpkg: error processing mscompress (--configure): subprocess installed post-installation script returned error exit status 1 No apport report written because MaxReports is reached already Errors were encountered while processing: netbase mtr-tiny module-init-tools mountmanager mono-4.0-gac mousetweaks mozilla-plugin-vlc mtools network-manager-pptp-gnome network-manager-pptp network-manager-gnome network-manager mscompress E: Sub-process /usr/bin/dpkg returned an error code (1)

    Read the article

  • Error "exit signal Bus error (7)" How to continue after making a backtrace?

    - by Mikel
    I have a Centos Server in 1and1 with Apache, Magento, MagentoBooster and Xcache installed. The server usually (1-8 times per day) prints this error "exit signal Bus error (7)" and sometimes this causes Apache not to respond. I have made a backtrace with GDB, but I don't know how to continue. gdb /usr/sbin/httpd core.XXXX --batch --quiet -ex "thread apply all bt full" backtrace.log The backtrace: [New Thread 15312] [Thread debugging using libthread_db enabled] Core was generated by `/usr/sbin/httpd'. Program terminated with signal 7, Bus error. #0 0x00002abcf6c7324e in memcpy () from /lib64/libc.so.6 Thread 1 (Thread 0x2abcf8c72300 (LWP 15312)): #0 0x00002abcf6c7324e in memcpy () from /lib64/libc.so.6 No symbol table info available. #1 0x00002abd02e6b9c7 in ?? () from /usr/lib64/php/modules//php_ioncube_loader_lin_5.2_x86_64.so No symbol table info available. #2 0x00002abd02ed4d47 in _zval_dup () from /usr/lib64/php/modules//php_ioncube_loader_lin_5.2_x86_64.so No symbol table info available. #3 0x00002abd02ecdffb in ?? () from /usr/lib64/php/modules//php_ioncube_loader_lin_5.2_x86_64.so No symbol table info available. #4 0x00002abd02c32636 in xc_compile_file (h=0x7fffc3e7e4f0, type=2) at /opt/xcache-1.3.2-rc1/xcache.c:1060 __orig_bailout = 0x7fffc3e88f10 __bailout = {{__jmpbuf = {46991244125792, 3379122525071325456, 46991369192208, 140736480142576, 140736480142656, 46991244125792, 3379207471940512272, 3379122524988693332}, __mask_was_saved = 0, __saved_mask = {__val = {46991369228841, 46991369206800, 46991369195208, 46991382361728, 46991369196536, 46991369206984, 46991369210744, 0, 46991240130544, 140733193388033, 0, 140736480142296, 46991240361284, 46991369207528, 46991369232128, 3}}}} sandbox = {alloc = 0, filename = 0x2abd078dd0e0 "/var/www/vhosts/DOMAIN/httpdocs/var/ait_rewrite/67b58abff9e6bd7b400bb2fc1903bf2f.php", orig_included_files = {nTableSize = 256, nTableMask = 255, nNumOfElements = 191, nNextFreeElement = 0, pInternalPointer = 0x2abcf4da53d0, pListHead = 0x2abcf4da53d0, pListTail = 0x2abd07dfeb28, arBuckets = 0x2abd0896d690, pDestructor = 0, persistent = 0 '\000', nApplyCount = 0 '\000', bApplyProtection = 1 '\001'}, tmp_included_files = 0x2abd0069e830, orig_zend_constants = 0x2abd0d630b60, tmp_zend_constants = {nTableSize = 2048, nTableMask = 2047, nNumOfElements = 1559, nNextFreeElement = 0, pInternalPointer = 0x2abd08283760, pListHead = 0x2abd08283760, pListTail = 0x2abd08320810, arBuckets = 0x2abd08302aa0, pDestructor = 0x2abd02c34850 <xc_free_zend_constant>, persistent = 1 '\001', nApplyCount = 0 '\000', bApplyProtection = 1 '\001'}, orig_function_table = 0x2abd0d61f340, orig_class_table = 0x2abd0d61f2b0, orig_auto_globals = 0x2abd0d618910, tmp_function_table = {nTableSize = 2048, nTableMask = 2047, nNumOfElements = 1555, nNextFreeElement = 0, pInternalPointer = 0x2abd08320ce0, pListHead = 0x2abd08320ce0, pListTail = 0x2abd0933fe60, arBuckets = 0x2abd079c8500, pDestructor = 0x2abd0033e1d0 <zend_function_dtor>, persistent = 1 '\001', nApplyCount = 0 '\000', bApplyProtection = 0 '\000'}, tmp_class_table = { nTableSize = 16, nTableMask = 15, nNumOfElements = 0, nNextFreeElement = 0, pInternalPointer = 0x0, pListHead = 0x0, pListTail = 0x0, arBuckets = 0x2abd079dbf60, pDestructor = 0x2abd0033dcf0 <destroy_zend_class>, persistent = 1 '\001', nApplyCount = 0 '\000', bApplyProtection = 0 '\000'}, tmp_auto_globals = {nTableSize = 16, nTableMask = 15, nNumOfElements = 9, nNextFreeElement = 0, pInternalPointer = 0x2abd0933ffc0, pListHead = 0x2abd0933ffc0, pListTail = 0x2abd093403e0, arBuckets = 0x2abd09340470, pDestructor = 0, persistent = 1 '\001', nApplyCount = 0 '\000', bApplyProtection = 0 '\000'}, tmp_internal_constant_tail = 0x2abd08320810, tmp_internal_function_tail = 0x2abd0933fe60, tmp_internal_class_tail = 0x0, orig_user_error_handler_error_reporting = 8191} op_array = <value optimized out> xce = {type = XC_TYPE_PHP, hvalue = 2460, next = 0x2abd0d939e60, cache = 0x2abd0d90b038, size = 10, refcount = 46991369191320, hits = 4, ctime = 46991362335072, atime = 8, dtime = 46991240673248, ttl = 46991369192096, name = {lval = 46991363920096, dval = 2.3216818564143281e-310, str = { val = 0x2abd078dd0e0 "/var/www/vhosts/DOMAIN/httpdocs/var/ait_rewrite/67b58abff9e6bd7b400bb2fc1903bf2f.php", len = 107}, ht = 0x2abd078dd0e0, obj = {handle = 126734560, handlers = 0x2abd0000006b}}, data = {php = 0x7fffc3e7e440, var = 0x7fffc3e7e440}, have_references = 0 '\000'} stored_xce = 0x0 php = {sourcesize = 8947, device = 64769, inode = 9907963, mtime = 1353055102, op_array = 0x2abd00344004, constinfo_cnt = 1, constinfos = 0x0, funcinfo_cnt = 132120232, funcinfos = 0x8, classinfo_cnt = 8, classinfos = 0x0, have_early_binding = 168 '\250', autoglobal_cnt = 10941, autoglobals = 0x8} cache = 0x2abd0d90b038 catched = <value optimized out> filename = <value optimized out> opened_path_buffer = "\000\000\000\000\000\000\000\000I\032\065\000\275*\000\000\300\347i\000\275*\000\000\001\000\000\000\000\000\000\000\377\377\377\377\000\000\000\000\000\000\000\000\003\000\000\000[\337\227\337,\002pr\n\000\000\000\000\000\000\000P\323\347\303\377\177\000\000\357\367\220\b\275*\000\000\243\002M\a\275*\000\000\005", '\000' <repeats 15 times>"\357, \367\220\b\275*\000\000\244\002M\a\275*\000\000Du0\000\275*\000\000\b\000\000\000\000\000\000\000\232b=\365\000\000\000\000\002\000\000\000\377\177\000\000\005\000\000\000\275*\000\000\220\322\347\303\377\177\000\000\000\020\000\000\000\000\000\000,\324\347\303\377\177\000\000`\321\347\303^", '\000' <repeats 27 times>, "\f\000\000 \001", '\000' <repeats 11 times>"\260, \322\347\303", '\000' <repeats 12 times>, "P\323\347\303\377\177\000\000x\225\332\364\004\000\000\000\001\000\000\000\031\000\000\000\300\331\336\a\275*\000\000\300\331\336\a\275*\000\000"... old_constinfo_cnt = 1559 old_funcinfo_cnt = 1555 old_classinfo_cnt = 0 #5 0x00002abd003290bf in compile_filename () from /etc/httpd/modules/libphp5.so No symbol table info available. #6 0x00002abd00398ded in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #7 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #8 0x00002abd0033b796 in zend_call_function () from /etc/httpd/modules/libphp5.so No symbol table info available. #9 0x00002abd0035b1e1 in zend_call_method () from /etc/httpd/modules/libphp5.so No symbol table info available. #10 0x00002abd00273bf4 in zif_spl_autoload_call () from /etc/httpd/modules/libphp5.so No symbol table info available. #11 0x00002abd0033b945 in zend_call_function () from /etc/httpd/modules/libphp5.so No symbol table info available. #12 0x00002abd0033c51e in zend_lookup_class_ex () from /etc/httpd/modules/libphp5.so No symbol table info available. #13 0x00002abd0033c728 in zend_fetch_class () from /etc/httpd/modules/libphp5.so No symbol table info available. #14 0x00002abd003a61ab in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #15 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #16 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #17 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #18 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #19 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #20 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #21 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #22 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #23 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #24 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #25 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #26 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #27 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #28 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #29 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #30 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #31 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #32 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #33 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #34 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #35 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #36 0x00002abd00366b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #37 0x00002abd0036628c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #38 0x00002abd00346943 in zend_execute_scripts () from /etc/httpd/modules/libphp5.so No symbol table info available. #39 0x00002abd00306898 in php_execute_script () from /etc/httpd/modules/libphp5.so No symbol table info available. #40 0x00002abd003cb09d in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #41 0x00002abcf4cfca0a in ap_run_handler () No symbol table info available. #42 0x00002abcf4cffe98 in ap_invoke_handler () No symbol table info available. #43 0x00002abcf4d0a74a in ap_internal_redirect () No symbol table info available. #44 0x00002abcfdb45bf0 in ap_make_dirstr_parent () from /etc/httpd/modules/mod_rewrite.so No symbol table info available. #45 0x00002abcf4cfca0a in ap_run_handler () No symbol table info available. #46 0x00002abcf4cffe98 in ap_invoke_handler () No symbol table info available. #47 0x00002abcf4d0a8f8 in ap_process_request () No symbol table info available. #48 0x00002abcf4d07b30 in ?? () No symbol table info available. #49 0x00002abcf4d03c92 in ap_run_process_connection () No symbol table info available. #50 0x00002abcf4d0e7a9 in ?? () No symbol table info available. #51 0x00002abcf4d0ea3a in ?? () No symbol table info available. #52 0x00002abcf4d0f29d in ap_mpm_run () No symbol table info available. #53 0x00002abcf4ce9e48 in main () No symbol table info available. Can anyone help me? ADITIONAL INFO php -v PHP 5.2.10 (cli) (built: Nov 13 2009 11:44:05) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with XCache v1.3.2-rc1, Copyright (c) 2005-2011, by mOo with the ionCube PHP Loader v3.1.28, Copyright (c) 2002-2007, by ionCube Ltd. httpd -v Server version: Apache/2.2.3 Server built: May 4 2011 06:51:15 Apache modules: core prefork http_core mod_so mod_auth_basic mod_auth_digest mod_authn_file mod_authn_alias mod_authn_anon mod_authn_dbm mod_authn_default mod_authz_host mod_authz_user mod_authz_owner mod_authz_groupfile mod_authz_dbm mod_authz_default util_ldap mod_authnz_ldap mod_include mod_log_config mod_logio mod_env mod_ext_filter mod_mime_magic mod_expires mod_deflate mod_headers mod_usertrack mod_setenvif mod_mime mod_dav mod_status mod_autoindex mod_info mod_dav_fs mod_vhost_alias mod_negotiation mod_dir mod_actions mod_speling mod_userdir mod_alias mod_rewrite mod_proxy mod_proxy_balancer mod_proxy_ftp mod_proxy_http mod_proxy_connect mod_cache mod_suexec mod_disk_cache mod_file_cache mod_mem_cache mod_cgi mod_version mod_fcgid mod_perl mod_php5 mod_proxy_ajp mod_python mod_ssl Aditional modules: dbase ionCube Loader sysvsem sysvshm EDIT (November 18) I have disabled some suspicious modules and the error persist. The new backtrace: [New Thread 12403] [Thread debugging using libthread_db enabled] Core was generated by `/usr/sbin/httpd'. Program terminated with signal 7, Bus error. #0 0x00002b0c5754a24e in memcpy () from /lib64/libc.so.6 Thread 1 (Thread 0x2b0c59549300 (LWP 12403)): #0 0x00002b0c5754a24e in memcpy () from /lib64/libc.so.6 No symbol table info available. #1 0x00002b0c558519c7 in ?? () from /usr/lib64/php/modules//php_ioncube_loader_lin_5.2_x86_64.so No symbol table info available. #2 0x00002b0c558bad47 in _zval_dup () from /usr/lib64/php/modules//php_ioncube_loader_lin_5.2_x86_64.so No symbol table info available. #3 0x00002b0c558b3ffb in ?? () from /usr/lib64/php/modules//php_ioncube_loader_lin_5.2_x86_64.so No symbol table info available. #4 0x00002b0c60d650bf in compile_filename () from /etc/httpd/modules/libphp5.so No symbol table info available. #5 0x00002b0c60dd4ded in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #6 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #7 0x00002b0c60d77796 in zend_call_function () from /etc/httpd/modules/libphp5.so No symbol table info available. #8 0x00002b0c60d971e1 in zend_call_method () from /etc/httpd/modules/libphp5.so No symbol table info available. #9 0x00002b0c60cafbf4 in zif_spl_autoload_call () from /etc/httpd/modules/libphp5.so No symbol table info available. #10 0x00002b0c60d77945 in zend_call_function () from /etc/httpd/modules/libphp5.so No symbol table info available. #11 0x00002b0c60d7851e in zend_lookup_class_ex () from /etc/httpd/modules/libphp5.so No symbol table info available. #12 0x00002b0c60d78728 in zend_fetch_class () from /etc/httpd/modules/libphp5.so No symbol table info available. #13 0x00002b0c60de21ab in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #14 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #15 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #16 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #17 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #18 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #19 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #20 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #21 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #22 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #23 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #24 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #25 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #26 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #27 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #28 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #29 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #30 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #31 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #32 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #33 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #34 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #35 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #36 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #37 0x00002b0c60da2b91 in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #38 0x00002b0c60da228c in execute () from /etc/httpd/modules/libphp5.so No symbol table info available. #39 0x00002b0c60d82943 in zend_execute_scripts () from /etc/httpd/modules/libphp5.so No symbol table info available. #40 0x00002b0c60d42898 in php_execute_script () from /etc/httpd/modules/libphp5.so No symbol table info available. #41 0x00002b0c60e0709d in ?? () from /etc/httpd/modules/libphp5.so No symbol table info available. #42 0x00002b0c555d3a0a in ap_run_handler () No symbol table info available. #43 0x00002b0c555d6e98 in ap_invoke_handler () No symbol table info available. #44 0x00002b0c555e174a in ap_internal_redirect () No symbol table info available. #45 0x00002b0c5e41cbf0 in ap_make_dirstr_parent () from /etc/httpd/modules/mod_rewrite.so No symbol table info available. #46 0x00002b0c555d3a0a in ap_run_handler () No symbol table info available. #47 0x00002b0c555d6e98 in ap_invoke_handler () No symbol table info available. #48 0x00002b0c555e18f8 in ap_process_request () No symbol table info available. #49 0x00002b0c555deb30 in ?? () No symbol table info available. #50 0x00002b0c555dac92 in ap_run_process_connection () No symbol table info available. #51 0x00002b0c555e57a9 in ?? () No symbol table info available. #52 0x00002b0c555e5a3a in ?? () No symbol table info available. #53 0x00002b0c555e629d in ap_mpm_run () No symbol table info available. #54 0x00002b0c555c0e48 in main () No symbol table info available.

    Read the article

  • C sockets, chat server and client, problem echoing back.

    - by wretrOvian
    Hi This is my chat server : #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <string.h> #define LISTEN_Q 20 #define MSG_SIZE 1024 struct userlist { int sockfd; struct sockaddr addr; struct userlist *next; }; int main(int argc, char *argv[]) { // declare. int listFD, newFD, fdmax, i, j, bytesrecvd; char msg[MSG_SIZE], ipv4[INET_ADDRSTRLEN]; struct addrinfo hints, *srvrAI; struct sockaddr_storage newAddr; struct userlist *users, *uptr, *utemp; socklen_t newAddrLen; fd_set master_set, read_set; // clear sets FD_ZERO(&master_set); FD_ZERO(&read_set); // create a user list users = (struct userlist *)malloc(sizeof(struct userlist)); users->sockfd = -1; //users->addr = NULL; users->next = NULL; // clear hints memset(&hints, 0, sizeof hints); // prep hints hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; // get srver info if(getaddrinfo("localhost", argv[1], &hints, &srvrAI) != 0) { perror("* ERROR | getaddrinfo()\n"); exit(1); } // get a socket if((listFD = socket(srvrAI->ai_family, srvrAI->ai_socktype, srvrAI->ai_protocol)) == -1) { perror("* ERROR | socket()\n"); exit(1); } // bind socket bind(listFD, srvrAI->ai_addr, srvrAI->ai_addrlen); // listen on socket if(listen(listFD, LISTEN_Q) == -1) { perror("* ERROR | listen()\n"); exit(1); } // add listfd to master_set FD_SET(listFD, &master_set); // initialize fdmax fdmax = listFD; while(1) { // equate read_set = master_set; // run select if(select(fdmax+1, &read_set, NULL, NULL, NULL) == -1) { perror("* ERROR | select()\n"); exit(1); } // query all sockets for(i = 0; i <= fdmax; i++) { if(FD_ISSET(i, &read_set)) { // found active sockfd if(i == listFD) { // new connection // accept newAddrLen = sizeof newAddr; if((newFD = accept(listFD, (struct sockaddr *)&newAddr, &newAddrLen)) == -1) { perror("* ERROR | select()\n"); exit(1); } // resolve ip if(inet_ntop(AF_INET, &(((struct sockaddr_in *)&newAddr)->sin_addr), ipv4, INET_ADDRSTRLEN) == -1) { perror("* ERROR | inet_ntop()"); exit(1); } fprintf(stdout, "* Client Connected | %s\n", ipv4); // add to master list FD_SET(newFD, &master_set); // create new userlist component utemp = (struct userlist*)malloc(sizeof(struct userlist)); utemp->next = NULL; utemp->sockfd = newFD; utemp->addr = *((struct sockaddr *)&newAddr); // iterate to last node for(uptr = users; uptr->next != NULL; uptr = uptr->next) { } // add uptr->next = utemp; // update fdmax if(newFD > fdmax) fdmax = newFD; } else { // existing sockfd transmitting data // read if((bytesrecvd = recv(i, msg, MSG_SIZE, 0)) == -1) { perror("* ERROR | recv()\n"); exit(1); } msg[bytesrecvd] = '\0'; // find out who sent? for(uptr = users; uptr->next != NULL; uptr = uptr->next) { if(i == uptr->sockfd) break; } // resolve ip if(inet_ntop(AF_INET, &(((struct sockaddr_in *)&(uptr->addr))->sin_addr), ipv4, INET_ADDRSTRLEN) == -1) { perror("* ERROR | inet_ntop()"); exit(1); } // print fprintf(stdout, "%s\n", msg); // send to all for(j = 0; j <= fdmax; j++) { if(FD_ISSET(j, &master_set)) { if(send(j, msg, strlen(msg), 0) == -1) perror("* ERROR | send()"); } } } // handle read from client } // end select result handle } // end looping fds } // end while return 0; } This is my client: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <string.h> #define MSG_SIZE 1024 int main(int argc, char *argv[]) { // declare. int newFD, bytesrecvd, fdmax; char msg[MSG_SIZE]; fd_set master_set, read_set; struct addrinfo hints, *srvrAI; // clear sets FD_ZERO(&master_set); FD_ZERO(&read_set); // clear hints memset(&hints, 0, sizeof hints); // prep hints hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; // get srver info if(getaddrinfo(argv[1], argv[2], &hints, &srvrAI) != 0) { perror("* ERROR | getaddrinfo()\n"); exit(1); } // get a socket if((newFD = socket(srvrAI->ai_family, srvrAI->ai_socktype, srvrAI->ai_protocol)) == -1) { perror("* ERROR | socket()\n"); exit(1); } // connect to server if(connect(newFD, srvrAI->ai_addr, srvrAI->ai_addrlen) == -1) { perror("* ERROR | connect()\n"); exit(1); } // add to master, and add keyboard FD_SET(newFD, &master_set); FD_SET(STDIN_FILENO, &master_set); // initialize fdmax if(newFD > STDIN_FILENO) fdmax = newFD; else fdmax = STDIN_FILENO; while(1) { // equate read_set = master_set; if(select(fdmax+1, &read_set, NULL, NULL, NULL) == -1) { perror("* ERROR | select()"); exit(1); } // check server if(FD_ISSET(newFD, &read_set)) { // read data if((bytesrecvd = recv(newFD, msg, MSG_SIZE, 0)) < 0 ) { perror("* ERROR | recv()"); exit(1); } msg[bytesrecvd] = '\0'; // print fprintf(stdout, "%s\n", msg); } // check keyboard if(FD_ISSET(STDIN_FILENO, &read_set)) { // read data from stdin if((bytesrecvd = read(STDIN_FILENO, msg, MSG_SIZE)) < 0) { perror("* ERROR | read()"); exit(1); } msg[bytesrecvd] = '\0'; // send if((send(newFD, msg, bytesrecvd, 0)) == -1) { perror("* ERROR | send()"); exit(1); } } } return 0; } The problem is with the part where the server recv()s data from an FD, then tries echoing back to all [send() ]; it just dies, w/o errors, and my client is left looping :(

    Read the article

  • "The server closed the connection without sending any data"

    - by Toby
    Server setup The problem Diagnostic information What I've tried Specific Help needed 1. I have the following server setup: Debian Squeeze Linux 2.6.32-5-amd64 Apache2-mpm-prefork 2.2.16-6+squeeze10 PHP 5.3.3-7+squeeze14 This server is protected with the Suhosin Patch 0.9.9.1 Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100 Timeouts Connection: 300 - Keep-Alive: 15 Loaded Modules core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_auth_digest mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_ssl mod_status Wordpress 3.4.2 (Upgrading to 3.5 soon :) 2. The problem When I restart the server (sudo shutdown -r now), going to any website page results in the following error from the web browser (in this case, Google Chrome, but other browsers also show the same error). This error can also occur an hour or so after all is working ok, seemingly randomly, which is my biggest concern as it means my server is not reliable: No data received Unable to load the web page because the server sent no data. Here are some suggestions: Reload this web page later. Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data. 3. Diagnostic information The apache error log contains the folowing entries: [Fri Dec 14 22:23:27 2012] [notice] child pid 1955 exit signal Floating point exception (8) [Fri Dec 14 22:23:27 2012] [notice] child pid 1956 exit signal Floating point exception (8) [Fri Dec 14 22:23:29 2012] [notice] child pid 1957 exit signal Floating point exception (8) [Fri Dec 14 22:23:30 2012] [notice] child pid 1958 exit signal Floating point exception (8) [Fri Dec 14 22:23:32 2012] [notice] child pid 1959 exit signal Floating point exception (8) [Fri Dec 14 22:23:32 2012] [notice] child pid 1960 exit signal Floating point exception (8) [Fri Dec 14 22:23:34 2012] [notice] child pid 1961 exit signal Floating point exception (8) [Fri Dec 14 22:23:34 2012] [notice] child pid 1962 exit signal Floating point exception (8) 4. What I've tried a) I can 'fix' the website temporarily by resetting the server twice (resetting it once does not work) using the following commands. NB: the 'reload' option does not work, I have to use restart twice. However, the error can reoccur sometime later. sudo /etc/init.d/apache2 restart sudo /etc/init.d/apache2 restart b) I have tried disabling suhosin by uninstalling php5-suhosin, but a php info page still shows "This server is protected with the Suhosin Patch 0.9.9.1". I have tried putting Suhosin into simulation mode by creating a file /etc/php5/apache2/conf.d/suhosin.ini containing: [suhosin] suhosin.simulation = On The php info page shows the suhosin.ini file in the list of "Additional .ini files parsed" but the php info page still shows "This server is protected with the Suhosin Patch 0.9.9.1" c) Increasing the PHP memory limit In /etc/php5/apache2/ : ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit memory_limit = 512M d) Disabling all Wordpress plugins, and going back to the default theme. 5. Specific help needed I would very much like help in debugging what is going on here. I am not sure how to determine what processes are in the Apache error log which are exiting "[notice] child pid 1955 exit signal Floating point exception (8)", or what is causing them to exit. And whether suhosin is part of the problem (and how to disable it if it is). Thank you in advance for any advice or tips you can offer in helping me debug this.

    Read the article

  • problem with fork()

    - by john
    I'm writing a shell which forks, with the parent reading the input and the child process parsing and executing it with execvp. pseudocode of main method: do{ pid = fork(); print pid; if (p<0) { error; exit; } if (p>0) { wait for child to finish; read input; } else { call function to parse input; exit; } }while condition return; what happens is that i never seem to enter the child process (pid printed is always positive, i never enter the else). however, if i don't call the parse function and just have else exit, i do correctly enter parent and child alternatingly. full code: int main(int argc, char *argv[]){ char input[500]; pid_t p; int firstrun = 1; do{ p = fork(); printf("PID: %d", p); if (p < 0) {printf("Error forking"); exit(-1);} if (p > 0){ wait(NULL); firstrun = 0; printf("\n> "); bzero(input, 500); fflush(stdout); read(0, input, 499); input[strlen(input)-1] = '\0'; } else exit(0); else { if (parse(input) != 0 && firstrun != 1) { printf("Error parsing"); exit(-1); } exit(0); } }while(strcmp(input, "exit") != 0); return 0; }

    Read the article

  • Dismount USB External Drive using powershell

    - by JC
    Hello, I am attempting to dismount an external USB drive using powershell and I cannot successfuly do this. The following script is what I use: #get the Win32Volume object representing the volume I wish to eject $drive = Get-WmiObject Win32_Volume -filter "DriveLetter = 'F:'" #call dismount on that object there by ejecting drive $drive.Dismount($Force , $Permanent) I then check my computer to check if drive is unmounted but it is now. The boolean parameters $force and $permanent have been tried with different permutations to no avail. The exit code returned by the dismount command changes when the params are toggled. (0,0) = exit code 0 (0,1) = exit code 2 (1,0) = exit code 0 (1,1) = exit code 2 The documentation for exit code 2 indicates that there are existing mount points as a reason why it cannot dismount. Although I am trying to dismount the only mount point that exists so I am unsure what this exit code is trying to tell me. Having already trawled the web for people experiencing similar problems I have only found one additional command to try and that is the following: # executed after the .Dismount() command $drive.Put() This additional command does not help. I am running out of things to try, so any assistance anyone can give me would be greatly appreciated, Thanks.

    Read the article

  • SWFupload adding extra extension?

    - by st4ck0v3rfl0w
    Hi Everyone, I've been struggling with this for a half day and can't seem to figure out why SWFupload is adding an extra extension to my uploads? (e.g. burer.jpg.jpg) I've reviewed the below code a thousand times and can't figure out why my files (whether png, gif or jpg) get an added .jpg extension? <?php $POST_MAX_SIZE = ini_get('post_max_size'); $unit = strtoupper(substr($POST_MAX_SIZE, -1)); $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1))); if ((int)$_SERVER['CONTENT_LENGTH'] > $multiplier*(int)$POST_MAX_SIZE && $POST_MAX_SIZE) { header("HTTP/1.1 500 Internal Server Error"); // This will trigger an uploadError event in SWFUpload echo "POST exceeded maximum allowed size."; exit(0); } // Settings $save_path = "/home/images/"; $upload_name = "image"; $max_file_size_in_bytes = 2147483647; // 2GB in bytes $extension_whitelist = array("jpg", "gif", "png", "jpeg"); // Allowed file extensions $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format) // Other variables $MAX_FILENAME_LENGTH = 260; $file_name = ""; $file_extension = ""; $uploadErrors = array( 0=>"There is no error, the file uploaded successfully", 1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini", 2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", 3=>"The uploaded file was only partially uploaded", 4=>"No file was uploaded", 6=>"Missing a temporary folder" ); // Validate the upload if (!isset($_FILES[$upload_name])) { HandleError("No upload found in \$_FILES for " . $upload_name); exit(0); } else if (isset($_FILES[$upload_name]["error"]) && $_FILES[$upload_name]["error"] != 0) { HandleError($uploadErrors[$_FILES[$upload_name]["error"]]); exit(0); } else if (!isset($_FILES[$upload_name]["tmp_name"]) || !@is_uploaded_file($_FILES[$upload_name]["tmp_name"])) { HandleError("Upload failed is_uploaded_file test."); exit(0); } else if (!isset($_FILES[$upload_name]['name'])) { HandleError("File has no name."); exit(0); } // Validate the file size (Warning: the largest files supported by this code is 2GB) $file_size = @filesize($_FILES[$upload_name]["tmp_name"]); if (!$file_size || $file_size > $max_file_size_in_bytes) { HandleError("File exceeds the maximum allowed size"); exit(0); } if ($file_size <= 0) { HandleError("File size outside allowed lower bound"); exit(0); } // Validate file name (for our purposes we'll just remove invalid characters) $file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", $_FILES[$upload_name]['name']); if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) { HandleError("Invalid file name"); exit(0); } // Validate file extension $path_info = pathinfo($_FILES[$upload_name]['name']); $file_extension = $path_info["extension"]; $is_valid_extension = false; foreach ($extension_whitelist as $extension) { if (strcasecmp($file_extension, $extension) == 0) { $is_valid_extension = true; break; } } if (!$is_valid_extension) { HandleError("Invalid file extension"); exit(0); } if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path.$file_name)) { HandleError("File could not be saved."); exit(0); } HandleError($_FILES[$upload_name]['name']); exit(0); function HandleError($message) { echo $message; } ?>

    Read the article

  • How to exit grid with ctrl-TAB when grid is on a tabpage (onkeydown works when grid not on tabpage)

    - by Charles Hankey
    winforms .net 3.5 Ultrawingrid 9.2 In my subclass of Ultrawingrid.Ultragrid : Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs) If e.KeyCode = Windows.Forms.Keys.Tab andalso e.control = True then SetFocusToNextControl(True) End if Mybase.OnKeyDown(e) End Sub This works fine. But when the grid is dropped on a TabControl tabpage, the ctrl-tab looks very different to the sub above. e.keycode is seen as controlkey {17} I realize that by default cntrl-Tab moves between tabpages. I need to override this behavior. My thought is I probably need a subclass of the tabControl which will pass the keycombo through just as the form does but I confess to being clueless as to how to accomplish that. I tried to override the onkeydown of a tabcontrol subclass and just issuing a return and not and base call to onkeydown if the ctrl-tab combo was pressed but it seemed to see the e.keycode as controlkey as well. FWIW I tried a different combination like ctrl-E and got pretty much the same result with focus disappearing from the grid but not going anywhere I could detect. The sub still saw the e.control as controlkey. Oddly, ctrl-X, ctrl-A etc all work in the grid and a ctrl-Delete combo I put in the subclass for deleting a row works fine. Once again - grid directly on form and it all works. I'm definitely over my head on this one. Guidance much appreciated. vb or c# fine. TIA

    Read the article

  • Why does C# exit when calling the Ada elaboration routine using debug?

    - by erict
    I have a DLL created in Ada using GPS. I am dynamically loading it and calling it successfully both from Ada and from C++. But when I try to call it from C#, the program exits on the call to Elaboration init. What am I missing? The exact same DLL is perfectly happy getting called from C++ and Ada. Edit: If I start the program without Debugging, it also works with C#. But if I run it with the Debugger, then it exits on the call to ElaborationInit. There are no indications in any of the Windows event logs. If the Ada DLL is Pure, and I skip the elaboration init call, the actual function DLL is called correctly, so it has something to do with the elaboration. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace CallingDLLfromCS { class Program { [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern IntPtr LoadLibrary(string dllToLoad); [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)] public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool FreeLibrary(IntPtr hModule); [UnmanagedFunctionPointer(CallingConvention.StdCall)] delegate int AdaCallable2_dlgt(int val); static AdaCallable2_dlgt fnAdaCallable2 = null; [UnmanagedFunctionPointer(CallingConvention.StdCall)] delegate void ElaborationInit_dlgt(); static ElaborationInit_dlgt ElaborationInit = null; [UnmanagedFunctionPointer(CallingConvention.StdCall)] delegate void AdaFinal_dlgt(); static AdaFinal_dlgt AdaFinal = null; static void Main(string[] args) { int result; bool fail = false; // assume the best IntPtr pDll2 = LoadLibrary("libDllBuiltFromAda.dll"); if (pDll2 != IntPtr.Zero) { // Note the @4 is because 4 bytes are passed. This can be further reduced by the use of a DEF file in the DLL generation. IntPtr pAddressOfFunctionToCall = GetProcAddress(pDll2, "AdaCallable@4"); if (pAddressOfFunctionToCall != IntPtr.Zero) { fnAdaCallable2 = (AdaCallable2_dlgt)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(AdaCallable2_dlgt)); } else fail = true; pAddressOfFunctionToCall = GetProcAddress(pDll2, "DllBuiltFromAdainit"); if (pAddressOfFunctionToCall != IntPtr.Zero) { ElaborationInit = (ElaborationInit_dlgt)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(ElaborationInit_dlgt)); } else fail = true; pAddressOfFunctionToCall = GetProcAddress(pDll2, "DllBuiltFromAdafinal"); if (pAddressOfFunctionToCall != IntPtr.Zero) AdaFinal = (AdaFinal_dlgt)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(AdaFinal_dlgt)); else fail = true; if (!fail) { ElaborationInit.Invoke(); // ^^^^^^^^^^^^^^^^^^^^^^^^^ FAILS HERE result = fnAdaCallable2(50); Console.WriteLine("Return value is " + result.ToString()); AdaFinal(); } FreeLibrary(pDll2); } } } }

    Read the article

  • Is there a way to exit a Greasemonkey script?

    - by SimpleCoder
    I know that you can use return; to return from a Greasemonkey script, but only if you aren't in another function. For example, this won't work: // Begin greasemonkey script function a(){ return; // Only returns from the function, not the script } // End greasemonkey script Is there a built in Greasemonkey function that would allow me to halt execution of the script, from anywhere in the script? Thank you,

    Read the article

  • how can I exit from a php script and continue right after the script?

    - by Samir Ghobril
    Hey guys, I have this piece of code, and when I add return after echo(if there is an error and I need to continue right after the script) I can't see the footer, do you know what the problem is? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en" > <head> <title>Login | JM Today </title> <link href="Mainstyles.css" type="text/css" rel="stylesheet" /> </head> <body> <div class="container"> <?php include("header.php"); ?> <?php include("navbar.php"); ?> <?php include("cleanquery.php") ?> <div id="wrap"> <?php ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); $conn=mysql_connect("localhost", "***", "***") or die(mysql_error()); mysql_select_db('jmtdy', $conn) or die(mysql_error()); if(isset($_POST['sublogin'])){ if(( strlen($_POST['user']) >0) && (strlen($_POST['pass']) >0)) { checklogin($_POST['user'], $_POST['pass']); } elseif((isset($_POST['user']) && empty($_POST['user'])) || (isset($_POST['pass']) && empty($_POST['pass']))){ echo '<p class="statusmsg">You didn\'t fill in the required fields.</p><br/><input type="button" value="Retry" onClick="location.href='."'login.php'\">"; return; } } else{ echo '<p class="statusmsg">You came here by mistake, didn\'t you?</p><br/><input type="button" value="Retry" onClick="location.href='."'login.php'\">"; return; } function checklogin($username, $password){ $username=mysql_real_escape_string($username); $password=mysql_real_escape_string($password); $result=mysql_query("select * from users where username = '$username'"); if($result != false){ $dbArray=mysql_fetch_array($result); $dbArray['password']=mysql_real_escape_string($dbArray['password']); $dbArray['username']=mysql_real_escape_string($dbArray['username']); if(($dbArray['password'] != $password ) || ($dbArray['username'] != $username)){ echo '<p class="statusmsg">The username or password you entered is incorrect. Please try again.</p><br/><input type="button" value="Retry" onClick="location.href='."'login.php'\">"; return; } $_SESSION['username']=$username; $_SESSION['password']=$password; if(isset($_POST['remember'])){ setcookie("jmuser",$_SESSION['username'],time()+60*60*24*356); setcookie("jmpass",$_SESSION['username'],time()+60*60*24*356); } } else{ echo'<p class="statusmsg"> The username or password you entered is incorrect. Please try again.</p><br/>input type="button" value="Retry" onClick="location.href='."'login.php'\">"; return; } } ?> </div> <br/> <br/> <?php include("footer.php") ?> </div> </body> </html>

    Read the article

  • Is it possible to exit a for before time in C++, if an ending condition is reached?

    - by tunnuz
    Hello, I want to know if it is possible to end a for loop in C++ when an ending condition (different from the reacheing right number of iterations) is verified. For instance: for (int i = 0; i < maxi; ++i) for (int j = 0; j < maxj; ++j) // But if i == 4 < maxi AND j == 3 < maxj, // then jump out of the two nested loops. I know that this is possible in Perl with the next LABEL or last LABEL calls and labeled blocks, is it possible to do it in C++ or I should use a while loop? Thank you.

    Read the article

  • How to exit from Native video player in Blackberry?

    - by Rajapandian
    Hi, I created one blackberry application which will play a video on a button click.This is my code, invocation=new Invocation("file:///SDCard/Blackberry/videos/PlayingVideo/funny.mp4"); registry=Registry.getRegistry("net.rim.device.api.content.BlackBerryContentHandler"); try { registry.invoke(invocation); } catch(Exception e) { } Now i can play the Video file.After clicking the Back button the native player is going to the background.It always running in the background.But i want to close that player.I have no idea about how to do it.Anybody knows please help me.

    Read the article

  • How do I make a background thread in Java that allows the main application to exit completely? This

    - by Bob
    I have a Java application that creates a new thread to do some work. I can launch the new thread with no problems. When the "main" program terminates, I want the thread I created to keep running - which it does... But the problem is, when I run the main application from Eclipse or from Ant under Windows, control doesn't return unless the background process is killed. If I fork the main java process in ant, I want control to return to ant once the main thread is done with its work... But as it is, ant continues to wait until both the main process and the created thread are both terminated. How do I launch the thread in the background such that control will return to ant when the "main" application is finished? (By the way, when I run the same application under Linux, I am able to do this with no problems).

    Read the article

  • How do I exit a series of If / else conditions in a mysql trigger?

    - by ScArcher2
    I have a trigger that checks to see if certain fields changed during the update. If any of these fields changed I update another table. I'd like to "break" out of the if conditions as soon as I know that something changed. Is there a way to do this within a MySQL Trigger? What I have works, but It seems inefficient. CREATE TRIGGER profile_trigger BEFORE UPDATE ON profile FOR EACH ROW BEGIN DECLARE changed INTEGER; SET changed = 0; IF STRCMP(NEW.first_name, OLD.first_name) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.last_name, OLD.last_name) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.maiden_name, OLD.maiden_name) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.suffix, OLD.suffix) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.title, OLD.title) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.gender, OLD.gender) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.street, OLD.street) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.street2, OLD.street2) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.city, OLD.city) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.state, OLD.state) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.zip, OLD.zip) <> 0 THEN SET changed = 1; ELSEIF STRCMP(NEW.home_phone, OLD.home_phone) <> 0 THEN SET changed = 1; ELSEIF NEW.date_of_birth <> OLD.date_of_birth THEN SET changed = 1; END IF; IF changed > 0 THEN update other_table set updated = CURRENT_TIMESTAMP where id = NEW.id; END IF; END; |

    Read the article

  • Is throwing an exception a healthy way to exit?

    - by ramaseshan
    I have a setup that looks like this. class Checker { // member data Results m_results; // see below public: bool Check(); private: bool Check1(); bool Check2(); // .. so on }; Checker is a class that performs lengthy check computations for engineering analysis. Each type of check has a resultant double that the checker stores. (see below) bool Checker::Check() { // initilisations etc. Check1(); Check2(); // ... so on } A typical Check function would look like this: bool Checker::Check1() { double result; // lots of code m_results.SetCheck1Result(result); } And the results class looks something like this: class Results { double m_check1Result; double m_check2Result; // ... public: void SetCheck1Result(double d); double GetOverallResult() { return max(m_check1Result, m_check2Result, ...); } }; Note: all code is oversimplified. The Checker and Result classes were initially written to perform all checks and return an overall double result. There is now a new requirement where I only need to know if any of the results exceeds 1. If it does, subsequent checks need not be carried out(it's an optimisation). To achieve this, I could either: Modify every CheckN function to keep check for result and return. The parent Check function would keep checking m_results. OR In the Results::SetCheckNResults(), throw an exception if the value exceeds 1 and catch it at the end of Checker::Check(). The first is tedious, error prone and sub-optimal because every CheckN function further branches out into sub-checks etc. The second is non-intrusive and quick. One disadvantage is I can think of is that the Checker code may not necessarily be exception-safe(although there is no other exception being thrown anywhere else). Is there anything else that's obvious that I'm overlooking? What about the cost of throwing exceptions and stack unwinding? Is there a better 3rd option?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >